June 12, 2018 at 9:02 am
Hi All,
Not sure if anyone has come accross something like this previously.
Got a simple select query which creates 2 different query plans even with hard coded values instead of parameters.
However this only happens when running through an API with Middleware but when we add a delay no issues.
Checked extended events to ensure the queries are being produced exactly the same.
Cleared the current plans from the cache (test environment)
Checked all indexes along with statistics and fragmentation.
Any other ideas would be gratefully received .
June 12, 2018 at 9:04 am
daniel.hughes 66721 - Tuesday, June 12, 2018 9:02 AMHi All,Not sure if anyone has come accross something like this previously.
Got a simple select query which creates 2 different query plans even with hard coded values instead of parameters.
However this only happens when running through an API with Middleware but when we add a delay no issues.
Checked extended events to ensure the queries are being produced exactly the same.
Cleared the current plans from the cache (test environment)
Checked all indexes along with statistics and fragmentation.Any other ideas would be gratefully received .
Not based on what you have posted.
June 12, 2018 at 9:08 am
Hi,
I encountered this kind of issues due to mismatch between the SET properties in the workload. I guess you are getting two plans as you are running one through SQL instance and the other one from your API (please check SET ARITHABORT option is matching in both the cases or not). Just go to properties of the query plans and investigate the SET properties there.
Thanks,
Debasis
June 12, 2018 at 9:11 am
debasis.yours - Tuesday, June 12, 2018 9:08 AMHi,I encountered this kind of issues due to mismatch between the SET properties in the workload. I guess you are getting two plans as you are running one through SQL instance and the other one from your API (please check SET ARITHABORT option is matching in both the cases or not). Just go to properties of the query plans and investigate the SET properties there.
Thanks,
Debasis
Interesting, something to put in a notebook should I encounter such an issue. Thanks for posting this.
June 12, 2018 at 9:12 am
debasis.yours - Tuesday, June 12, 2018 9:08 AMHi,I encountered this kind of issues due to mismatch between the SET properties in the workload. I guess you are getting two plans as you are running one through SQL instance and the other one from your API (please check SET ARITHABORT option is matching in both the cases or not). Just go to properties of the query plans and investigate the SET properties there.
Thanks,
Debasis
Thanks Debasis shall have a look π
June 12, 2018 at 9:17 am
dannydudek - Tuesday, June 12, 2018 9:02 AMHi All,Not sure if anyone has come accross something like this previously.
Got a simple select query which creates 2 different query plans even with hard coded values instead of parameters.
However this only happens when running through an API with Middleware but when we add a delay no issues.
Checked extended events to ensure the queries are being produced exactly the same.
Cleared the current plans from the cache (test environment)
Checked all indexes along with statistics and fragmentation.Any other ideas would be gratefully received .
Can you post up both plans?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 12, 2018 at 9:22 am
June 12, 2018 at 9:25 am
dannydudek - Tuesday, June 12, 2018 9:22 AM
As .sqlplan attachments - the property sheets are important π
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
June 12, 2018 at 11:54 am
dannydudek - Tuesday, June 12, 2018 9:02 AMHi All,Not sure if anyone has come accross something like this previously.
Got a simple select query which creates 2 different query plans even with hard coded values instead of parameters.
However this only happens when running through an API with Middleware but when we add a delay no issues.
Checked extended events to ensure the queries are being produced exactly the same.
Cleared the current plans from the cache (test environment)
Checked all indexes along with statistics and fragmentation.Any other ideas would be gratefully received .
If you query the plans and use sys.dm_exec_plan_attributes, you can get the differences with set options as well as other properties. Pay attention to user_id as despite it's name it will indicate a plan is sharable or not. It works great for situations such as these:
sys.dm_exec_plan_attributes
Sue
June 12, 2018 at 12:35 pm
debasis.yours - Tuesday, June 12, 2018 9:08 AMHi,I encountered this kind of issues due to mismatch between the SET properties in the workload. I guess you are getting two plans as you are running one through SQL instance and the other one from your API (please check SET ARITHABORT option is matching in both the cases or not). Just go to properties of the query plans and investigate the SET properties there.
Thanks,
Debasis
+100000! This is actually a very common problem and it's not just a problem with different query plans. A lot of devs don't understand how their stuff works with NULL = NULL through the API but the same query in SSMS doesn't work correctly.
Someone mark Debasis' post as the "correct" answer! π
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply