Single table and combined double structure performance

It is not a question of using another tool. This is not about using a different data structure. This is a question about WHY . I see what I see - please read it to the end before replying. Thank.

STORY

I have one table that has one condition, records are not deleted. Instead, the record is marked as inactive (there is a field for this), and in this case all fields (except identifiers and this Activation field) are considered irrelevant.

More about identifiers - there are two fields:

  • id - int, primary key, clustered
  • name - unique, varchar, external index

How the update is performed, for example, (I use C # / Linq / MSSQL2005): I retrieve the record based on the name, then change the necessary fields and commit the changes, so the update is performed (UPDATE uses id, not name).

However, there is a problem with storage. So, why not split this table into a double structure - the header table (id, name, isActive) and the data table (id, other fields). In case of a storage problem, we can delete all records from the data table for real (for isActive = false).

edit (by Shimmy): header + data is not extracted LINQ with the connection. Data records are loaded on demand (and this is always due to code).

comment (by poster): AFAIR there is no connection, so it does not matter. Heading data was downloaded manually. See below.

Performance - (my) Theory

, ? ? , 10000 (, , ), ( 3 ) - areActive .

/:

  • mono table - , , , .

  • - , , , ( , ), , .

, - , .

, , , , , (), 30% . - , // , .

- / ?

+3
3

, , , .

SELECT - . -, , , , . .

INSERT - , .

UPDATE - isActive, , , . "isActive". "isActive".

, . , , "", , , . , , , , , . !. , , . , , , , - .

, - ! - . - .

, .

+1

: Sql .

Sql , . - .

, , , - , . , . , ( , , ..) , .

+1

? .

, . , . -, , .

In addition, the locks are more detailed - the first update can be written to table1, and then the second update can be written to table1 until you finish table2.

0
source

Source: https://habr.com/ru/post/1731337/


All Articles