Friday, March 23, 2012

Query plans

Hi all,
I read somewhere that you should write the fully qualified name for a table(db.dbo.table) in order to have a better chance to match the statement to a queryplan/execution plan..

Ive tested it to some of the tables in your db with different results, in some cases the query without the "complete path" was up to 3 times heavier to execute(relatively to the batch) than the same query with qualified path(i ran the two at the same time with show execution plan).

Sometimes there was no difference at all 50%-50% cost. And i wasent able to find any logic reason for the sometimes quicker execution with qualified path, sometimes a didnt even had any statistics created for the column in the where clause when the question was faster than the other one.

type of statements executed:
Select Col1,Col2 From db.dbo.table1
Select Col1,Col2 From table1

Does anyone know exactly how this works?

Any help would be mostly appreciated
JonasThe times that they were equal - were both queries on the fast side or slow side ?|||"The times that they were equal - were both queries on the fast side or slow side ?"

I really dont know..They where both executed with the same cost. My guess is that both queries where matched to an existing execution plan and should therefor been on the fast side.

Q2: Lets say that we have a stored proc that is compiled and sqlserver has generated a execution plan for it, right. Does the created execution plan uses other already created plans for the statements in the proc or does it creates a completely new one just for the statments in the proc?|||Take a look at Recompilng a Stored Procedure in bol. If you need more information or a better explanation, let me know.

No comments:

Post a Comment