August 7, 2014 at 2:46 am
Do multiple SELECT queries on the same table but different condition in WHERE clause block or affect each other in any way?
August 7, 2014 at 2:48 am
They do not block each other, but they compete for the same resources of course (mainly IO I guess).
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
August 7, 2014 at 2:53 am
Thanks for the reply.
All I want to know is whether it will affect the query execution time?
August 7, 2014 at 2:54 am
gstarsaini (8/7/2014)
Thanks for the reply.All I want to know is whether it will affect the query execution time?
It might. Depends on the queries and how often they are executed.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
August 7, 2014 at 8:08 am
gstarsaini (8/7/2014)
Do multiple SELECT queries on the same table but different condition in WHERE clause block or affect each other in any way?
They definitely could. The WHERE conditions determine which row(s) match. But the lock(s) are on the underlying row(s)|page(s) themselves. Therefore, blocking could occur no matter the WHERE conditions are. Indeed, a SELECT without a WHERE clause could block other queries at certain times as well.
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".
August 7, 2014 at 8:31 am
Readers don't block readers. Readers can block writers and the other way around. Even on that case, it would depend on the locks acquired based on the queries and the indexes available in the table.
August 7, 2014 at 8:41 am
Thanks for the reply.
This means there is no effect on the queries?
August 7, 2014 at 8:47 am
gstarsaini (8/7/2014)
Thanks for the reply.This means there is no effect on the queries?
Each reply posted to your question implies "maybe", "probably" or "definitely". The average of these isn't "definitely not"!
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
August 7, 2014 at 9:05 am
Thanks again.
Avoid sarcasm. Don't insist on the last word.
August 7, 2014 at 9:10 am
ChrisM@Work (8/7/2014)
gstarsaini (8/7/2014)
Thanks for the reply.This means there is no effect on the queries?
Each reply posted to your question implies "maybe", "probably" or "definitely". The average of these isn't "definitely not"!
No, definitely could. Hint(s) in a SELECT can cause them to take higher-level locks. The SELECT could be part of an UPDATE statement.
Yes, pure SELECT-only should never cause blocking with another pure SELECT-only.
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".
August 7, 2014 at 9:19 am
ScottPletcher (8/7/2014)
ChrisM@Work (8/7/2014)
gstarsaini (8/7/2014)
Thanks for the reply.This means there is no effect on the queries?
Each reply posted to your question implies "maybe", "probably" or "definitely". The average of these isn't "definitely not"!
No, definitely could. Hint(s) in a SELECT can cause them to take higher-level locks. The SELECT could be part of an UPDATE statement.
Yes, pure SELECT-only should never cause blocking with another pure SELECT-only.
But will most likely affect performance (even if only slightly), which is part of OP's question.
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
August 7, 2014 at 9:26 am
ChrisM@Work (8/7/2014)
ScottPletcher (8/7/2014)
ChrisM@Work (8/7/2014)
gstarsaini (8/7/2014)
Thanks for the reply.This means there is no effect on the queries?
Each reply posted to your question implies "maybe", "probably" or "definitely". The average of these isn't "definitely not"!
No, definitely could. Hint(s) in a SELECT can cause them to take higher-level locks. The SELECT could be part of an UPDATE statement.
Yes, pure SELECT-only should never cause blocking with another pure SELECT-only.
But will most likely affect performance (even if only slightly), which is part of OP's question.
Quite true as well.
Which is why I don't quite understand the "definitely not!" 🙂
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".
August 7, 2014 at 9:34 am
ScottPletcher (8/7/2014)
Which is why I don't quite understand the "definitely not!" 🙂
You may have missed the word before that phrase.
"The average of those isn't 'definitely not'"
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 7, 2014 at 9:37 am
GilaMonster (8/7/2014)
ScottPletcher (8/7/2014)
Which is why I don't quite understand the "definitely not!" 🙂You may have missed the word before that phrase.
"The average of those isn't 'definitely not'"
Yep, sure did :blush:
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".
August 8, 2014 at 12:46 am
Thanks you.This will help.
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply