Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Best way to delete records
Message
 
 
À
20/08/2010 09:12:22
Jerry Tovar
Dana Corporation Dana It
Maumee, Ohio, États-Unis
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
01477531
Message ID:
01477534
Vues:
42
>We have a SQL Server table(table_1) that we occasionally need to perform several
>thousand deletes on. This table has several other tables(table_2, table_3, table_4)
>with foreign keys defined to the PK in table_1.
>
>Would it be more efficient to enable ON DELETE CASCADE on the
>child tables and then in our stored procedure delete table_1 records in batches?
>
>Or would it be better to not enable ON DELETE CASCADE, then in our
>stored procedure perform the deletes
>on table_2, table_3, table_4 then lastly table_1, and perform the deletes in batches?
>
>We want to avoid blocking and make this as efficient as possible.

I think DELETE CASCADE is a good option. You may want to do your deletes in batches - the optimal batch size you need to determine based on many factors.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform