Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Stored Procedures: Optimizing Queries

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-02-11 : 18:50:08
Philip writes "This is a two-parter:

If I'm calling a stored procedure from ASP, which of the following procs (entire code not shown) would execute faster, assuming that the fields containing "ID" are primary keys and indexed in the respective tables...

Version 1:

SELECT @currentStepID = currentStepID
FROM users
WHERE userID = @userID

SELECT @currentStepURL = stepURL
FROM steps
WHERE stepID = @currentStepID

Note: @currentStepID is a local variable, @userID is an input parameter, @currentStepURL is an output parameter

Version 2:

SELECT @currentStepURL = s.stepURL
FROM users u
JOIN steps s
ON u.currentStepID = s.stepID
WHERE u.userID = @userID

Note: @userID is an input parameter, @currentStepURL is an output parameter

Part II:

How can I use the SQL Query Analyzer to compare the above? I plugged in both queries and performed an "Execution Plan," but can you provide some more insight on comparing "I/O cost", "CPU cost", "Subtree cost", etc.?

Thanks,

Philip Misiowiec
Webficient LLC"
   

- Advertisement -