Here's an snippet of the code I'm using... which do you think would be faster - or does it really make a difference?
The NOT IN statement scans the entire table to see if the KanbanID is actually in the table, and I'm guessing this is where the largest amount of time is used up.
Is there a quicker way to do this, or is this fairly efficient?
Note: The KBDATA table only has about 8000 records, but it grows almost daily, usually only by a couple hundred or so, but I have no idea how much it will grow before we have all the Kanban's we need.... *shrug*
What are your thoughts?
Code:
IF (@FORMVAL NOT IN (SELECT KanbanID FROM KBDATA))
BEGIN
DECLARE @ReturnVal decimal(3,0)
SET @ReturnVal = '-1'
RETURN @ReturnVal
END
IF (SELECT KBCLR FROM KBDATA WHERE KanbanID = @FORMVAL) NOT IN ('OR')
BEGIN
SET @ReturnVal = '-3'
RETURN @ReturnVal
END
IF (SELECT STATUS FROM KBDATA WHERE KanbanID = @FORMVAL) = '1'
BEGIN
SET @ReturnVal = '75'
RETURN @ReturnVal
END
Code:
[COLOR=green]Code currently in use...[/color]
IF (@FORMVAL NOT IN (SELECT KanbanID FROM KBDATA))
BEGIN
DECLARE @ReturnVal decimal(3,0)
SET @ReturnVal = '-1'
RETURN @ReturnVal
END
[COLOR=blue]ELSE IF[/color] (SELECT KBCLR FROM KBDATA WHERE KanbanID = @FORMVAL) NOT IN ('OR')
BEGIN
SET @ReturnVal = '-3'
RETURN @ReturnVal
END
[COLOR=blue]ELSE IF[/color] (SELECT STATUS FROM KBDATA WHERE KanbanID = @FORMVAL) = '1'
BEGIN
SET @ReturnVal = '75'
RETURN @ReturnVal
END
The NOT IN statement scans the entire table to see if the KanbanID is actually in the table, and I'm guessing this is where the largest amount of time is used up.
Is there a quicker way to do this, or is this fairly efficient?
Note: The KBDATA table only has about 8000 records, but it grows almost daily, usually only by a couple hundred or so, but I have no idea how much it will grow before we have all the Kanban's we need.... *shrug*
What are your thoughts?