Click here to Skip to main content
15,914,070 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
I have two tables, having parent-child relation. Each table contains around 14 lakh records. I want to delete data from the parent table along with the associated records in child table. The count of records to be deleted is around 4 lakh.
Directly firing a DELETE query in SQL freezes the database server. As the database is being used, I need a solution which will not cause the database to freeze. There are no indexes on both tables, but there are foreign keys in 4 other tables which reference a column of the child table (mentioned above).

Is there something which can speed up the delete process without freezing the database?


What I have tried:

I tried running a delete query on parent table which cascade delete the records from child table, but this freezes the database server. Currently i am using a console application(created using c#) which gets the list of folders and deleting them one by one.
Posted
Comments
Mehdi Gholam 24-Aug-16 8:58am    
What is your query?
Richard Deeming 24-Aug-16 9:26am    
If it actually freezes the server - ie: Windows is unresponsive - then your server is seriously underpowered.

If it's just causing other queries to time out, then it sounds like you've got more than two related tables, with CASCADE DELETE enabled.

Try deleting the rows in small batches.

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900