Comments
4 comments
-
I can suggest this change - how did you come to the conclusion that it would be better to change the order of the index drop? I tried recreating a facsimile of your table and indexes and analyzed the execution plan both ways it did not seem to be very different.
-
Probably because when a PK is dropped all other indexes featuring the PK IDs have their "secret columns" removed as the table is now a heap.
Like I said. "I could be wrong" but that was how I understood the behavior to work. -
I will give you credit where credit is due - switching the indexes around makes the query run consistently 5 seconds faster on my server. It looks like there are a lot more latches going on.
If you are using Source Control, it may be a good idea to put a migrations script there to change the order. I can log a bug on this side but it doesn't seem to be a critical issue. -
Thanks Brian.
For completeness, the table in question contains about 110MM rows, which takes considerably longer to alter with the NCI in place.
Haven't yet got the hang of migration scripts in SSC - too much else going on to spend time on them, to be honest, so I keep my scripts in sequence in the file system and run them manually. Thankfully with only one target production server per application, it's not arduous.
Best regards,
Stephen
Add comment
Please sign in to leave a comment.
In my case, I swapped the PK sequence of the 3rd and 4th columns along with dropping an obsolete index.
SC drops the PK then the non-clustered index, so perhaps it's doing unnecessary IO. With the table in question comprising over 110MM rows, this is a potential excessive-wait situation in the making...
(Sadly, I inherited the poorly chosen table and column names; they're pervasive, so I'm stuck with them for now, so please no observations on them...!)
Like I said, I could be wrong...
Here's the generated script: