SQL Server Efficiently dropping a group of rows with millions and millions of rows

前端 未结 13 568
遇见更好的自我
遇见更好的自我 2021-02-04 12:26

I recently asked this question: MS SQL share identity seed amongst tables (Many people wondered why)

I have the following layout of a table:

Table: Star

13条回答
  •  忘了有多久
    2021-02-04 13:24

    Just taking your idea of many tables - how can you realise that...

    What about using dynamic queries.

    1. create the table of categories that have identity category_id column.
    2. create the trigger on insert for this tale - in it create table for stars with the name dynamically made from category_id.
    3. create the trigger on delete - in it drop the corresponding stars table also with the help of dynamically created sql.
    4. to select stars of concrete category you can use function that returns table. It will take category_id as a parameter and return result also through dynamic query.
    5. to insert stars of new category you firstly insert new row in categories table and then insert stars to appropriate table.

    Another direction in which I would make some researches is using xml typed column for storing stars data. The main idea here is if you need to operate stars only by categories than why not to store all stars of concrete category in one cell of the table in xml format. Unfortunately I absolutely cannot imaging what will be the performance of such decision.

    Both this variants are just like ideas in brainstorm.

提交回复
热议问题