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)
 Question on query plans

Author  Topic 

tfountain
Constraint Violating Yak Guru

491 Posts

Posted - 2003-02-21 : 16:03:12
Suppose I have a procedure as follows:

CREATE PROCEDURE usp_MyTest
(
@ClientKey INT = NULL,
@EmployeeKey INT = NULL
)
AS

IF (@EmployeeKey IS NOT NULL)
SELECT * FROM Table WHERE EmployeeKey = @EmployeeKey
ELSE
SELECT * FROM Table WHERE ClientKey = @ClientKey

What are the performance implications (if any) of doing this?

SamC
White Water Yakist

3467 Posts

Posted - 2003-02-21 : 16:28:11

The overhead of an IF statement to determine which SELECT to execute. I wonder if anyone can quantify this, but I'd say the performance implications are so small they are immeasurable.

Sam

Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-02-21 : 16:32:44
I'd say that's probably faster than:

SELECT * FROM Table WHERE
EmployeeKey = @EmployeeKey
OR ((@EmployeeKey IS NULL) AND (ClientKey = @ClientKey ))

which I think would be the most efficient alternative done in 1 statement .... try them out!


- Jeff
Go to Top of Page
   

- Advertisement -