September 29, 2007 at 9:39 pm
Paul (5/3/2007)
Forget my original question...Make believe that this has nothing to do with cursors, stored procs or anything else. I just want to know if anyone has ever seen "Primary Key" assigned to a column in a table var, crash a stored proc.
That's it. That's the entire question.
I don't mean to sound ungratefulm but many people have posted answers to a question I am not asking. I am not attempting to speed up a stored proc, I am not attempting to alter my code. The code I have works fine. I am just asking if anyone else has ever seen this behavior in SQL 2000.
Thanks
Yes, I've seen it... many times... it usually happens when someone updates the primary key column of a table using a join with that same table and some parallelism takes place. It usually only occurs on production boxes because they are much more likely to spawn the right kind of parallelism.
And that's why we wanted you to post the code... so we can check.
--Jeff Moden
Change is inevitable... Change for the better is not.
November 10, 2008 at 4:48 am
Hi All,
I also ran into the exact problem (SS 2000)
I have a report which is timing out in all the environments (Offshore, Dev and QA).
The ASP report consists of a query which is using a table variable.
If I run the Report WITH primary key on the table variable it is taking 5 mins.
In the execution plan, the cost of table variable population is 16%
In the main query, cost of clustured index scan on table variable is 38% (even though table variable has only one row.)
If I run the query WITH OUT primary key on the table variable it is taking just 3 seconds.
In the execution plan, the cost of table variable population is 0.1%
In the main query, cost of table scan on table variable is 0%
This behavior is consistent across all DEV, QA and Prod Environments. It is very strange!!!!
Satya
November 10, 2008 at 6:05 am
That sounds more like problems with a table variable. Why aren't you using a temp table, instead?
--Jeff Moden
Change is inevitable... Change for the better is not.
November 10, 2008 at 6:09 am
China Satya Rao T (11/10/2008)
In the execution plan, the cost of table variable population is 0.1%In the main query, cost of table scan on table variable is 0%
The cost of operations against table variables cannot be considered accurate. Accurate costing requires that the optimiser knows how many rows will be affected and the optimiser cannot know that with table variables because they have no statistics.
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
November 10, 2008 at 9:25 pm
Jeff Moden (11/10/2008)
That sounds more like problems with a table variable. Why aren't you using a temp table, instead?
Heh... sorry... I forgot... you're happy with the code you have.
To answer your question... yes, I've seen the problem. It's usually in conjuction with Table Variables for when I've seen it and I don't know why.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply