Query running fast in production and slow in non-production
I have asked to look one of the queries that run fast in production and slow in non-production.
Question asked – how long it took to complete the results. It is about 1.50 minutes in non-production, but in production it completed less than 5 seconds.
Got the code and run myself in SSMS to compare the plan, since it will finish 1.50 minutes. It quickly showed estimated number of rows are totally different. This could be either out of stats or data skew.
I just checked the last stats update and updated the stats that fixed the issue.
You can easily compare execution plan in SSMS.