We have a dynamic SP that dependant on a user name will run a selected
tailored to them.
One of the criteria is the number of rows retrieved, which we include using
'top @varNoOfRows' in the dynamically created select .
As long as the number of rows is less than 130 the SP runs in less than a
second, but if you increase that value to over 150 the SP times out.
It is being run from ASP in this way: DBCon.execute(S QLQuery)
The main table that we are querying contains about 1.5 million records and
is un-indexed. (eek - didn't realise that until I just checked) on SQL
server 2000.
Does anyone have any pointers towards streamlining the SP - I can post it if
you wish. Or can anyone explain how to use the execute plan to our
advantage?
I've already used it to change a
SET @statement2 = (select T1_QueryPart from Table1 where T1_ID like (SELECT
LoginTable_T1ID from LoginTable where @username = LT_UserName)
)
to
SET @T1ID = (SELECT LT_T1ID from LoginTable where @username = LT_UserName)
SET @statement2 = (select T1_QueryPart from Table1 where T1_ID like @T1ID)
But would , say, a join be more time efficient?
Any help would be appreciated
John
tailored to them.
One of the criteria is the number of rows retrieved, which we include using
'top @varNoOfRows' in the dynamically created select .
As long as the number of rows is less than 130 the SP runs in less than a
second, but if you increase that value to over 150 the SP times out.
It is being run from ASP in this way: DBCon.execute(S QLQuery)
The main table that we are querying contains about 1.5 million records and
is un-indexed. (eek - didn't realise that until I just checked) on SQL
server 2000.
Does anyone have any pointers towards streamlining the SP - I can post it if
you wish. Or can anyone explain how to use the execute plan to our
advantage?
I've already used it to change a
SET @statement2 = (select T1_QueryPart from Table1 where T1_ID like (SELECT
LoginTable_T1ID from LoginTable where @username = LT_UserName)
)
to
SET @T1ID = (SELECT LT_T1ID from LoginTable where @username = LT_UserName)
SET @statement2 = (select T1_QueryPart from Table1 where T1_ID like @T1ID)
But would , say, a join be more time efficient?
Any help would be appreciated
John
Comment