February 15, 2023 at 7:56 pm
Hello!
Trying to delete about 1000 records from a table in Azure, not sure why it has been running for 2 hours and not giving any errors or completed?
Thanks.
February 16, 2023 at 1:56 pm
Almost impossible to tell you exactly what is wrong without more data. It could be as simple as you didn't commit your transaction. It could be blocking. Assuming you have no monitoring in place, I'd run some queries against sys.dm_exec_requests to see what is blocking your process (cause that's probably it, but hard to know without more data). Here's more information on the topic. It's also possible that it's an enormous data set, but your WHERE clause isn't using any indexes, so it's scanning the table to find everything to delete. I'd start with blocking though.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
February 16, 2023 at 6:44 pm
Thank you, I think the other factor is that there are more than 100 tables that have dependency on this table, so the delete might be looking into all those other dependent tables before trying to delete on parent table.
February 17, 2023 at 1:27 pm
Oh yeah, take a look at the execution plan. You can just get an estimated plan, you don't have to execute the query. That will show you all the activity that the engine is doing to satisfy the query. It could very well be all those dependent tables. That's what I mean when I said I didn't have enough information to tell you for sure why the query was running slow. Still, probably blocking. But now you have even more areas where blocking could be playing a factor.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
February 17, 2023 at 5:19 pm
Thank you, I think the other factor is that there are more than 100 tables that have dependency on this table, so the delete might be looking into all those other dependent tables before trying to delete on parent table.
If there are FKs involved, then most definitely.
I'm curious... why so many individual tables?
--Jeff Moden
Change is inevitable... Change for the better is not.
February 28, 2023 at 12:40 pm
If a FK or a trigger is involved i hope , there should be some kindly of error thrown?.
Regards
Durai Nagarajan
February 28, 2023 at 12:58 pm
If a FK or a trigger is involved i hope , there should be some kindly of error thrown?.
Not if it's just processing all the validations, scanning tables looking for matches, that sort of thing. No error, just lots of CPU, disk & memory, slowing it all down.
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
- Theodore Roosevelt
Author of:
SQL Server Execution Plans
SQL Server Query Performance Tuning
February 28, 2023 at 3:15 pm
You would also want to check what the FK DELETE options are on each table. For the ones that are CASCADE, that could cause updates in other tables as well (which, theoretically, could also flow to yet other tables).
SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply