Regd. Execution plan of the Query | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Regd. Execution plan of the Query

Hi All, I have a some question regarding the ExecutionPlan of the SqlServer. I have written two queries in my procedure.
First one is doing the query (using select statements) and inserting the rows into the temp table.
Second one is fetching the rows from this temp table and when fetching the rows, I am joining some of other tables along with this temp table. Now if i see the execution plan it is showing that 80% of the querycost is taking for the first query and remaining 20% for the second query. But I suspect this is wrong. Because definetly here the second query is large it will take lot of time.
Can anyone explain what’s wrong here? For me it seems like the cost of the query is no way related to the time taken by that query. Is it true? Any help is appreciated. Thx.
Mahesh Paranjpe
Post table structures and the queries you used Madhivanan Failing to plan is Planning to fail
You can run both and record the execution time for each. The execution time is not function of query size although there is corelation between them.
I ran the two queries seperately. The first query is taking lessthan a second. Where as the second query is taking upto 10secs.
But If i see the execution plan by running the two queries at a time, it is showing the cost of the query of the first one is 80% and second one is 20%.
Due to this I am unable to understand where and why the second query is taking time.

In that case obsolate statistics on one or more tables involved might be the reason.
Also recompile the stored procedure and triggers in order to obtain upto date statistics, in addition to refferred above. Satya SKJ
Contributing Editor & Forums Moderator
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
Thanx for the replies guys.
Now i am getting the right statistics in my procedure after using the Global temp table instead of using the local In-memory table.
But still I am surprised that it would effect the statistics.