April 16, 2009 at 7:13 pm
I write below script and run it in the SQL 2000 Query Analyzer many times, but I didn't find any executed plan in the syscacheobjects regarding below code.So if I use variable in the where condition of select statement and run it in the Query Analyzer, it will not generate any executed plan, is right? Thanks
Declare @s-2 varchar(20)
Set @s-2='ANTON'
select * from northwind.dbo.customers where customerid=@s
April 17, 2009 at 7:03 am
If it's considered a trivial execution plan, it won't cache the plan that's created. That looks like a plan that is likely trivial.
BTW, you're posting in the 2008 area for a 2000 question. If people don't read the post carefully they might suggest solutions that won't work for you. Be sure you post in the correct forum.
"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
April 18, 2009 at 1:46 am
Thank for your help!
but I run below two SQL statements,and can find executed plan for them.
this is why?
select * from northwind.dbo.customers
select * from northwind.dbo.customers where customerid='ANTON'
April 18, 2009 at 4:53 am
It honestly depends on what the optimizer considers to be a trivial plan. Here's an explanation of how plans are determined: http://msdn.microsoft.com/en-us/library/aa226174.aspx
"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
April 18, 2009 at 9:02 am
The first one won't really generate a plan. It needs to scan everything, so why build a plan?
The second one might use an index, but the "Select *" might just cause a scan as well.
IF you want to learn more about plans, I'd get Grant's e-book on plans and look for more complicated plans.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply