Ok Guys I have a problem. I'm sure someone know the answer to this. I'd appreciate any advice....
Query:
declare @PRODN_DATE_START datetime, @PRODN_DATE_END datetime
set @PRODN_DATE_START = '04/17/02'
set @PRODN_DATE_END = '04/17/02'
(SELECT COUNT(EVENT_TRACKER.EVENT_CD)
FROM
{ oj (EVENT_TRACKER INNER JOIN SOURCE_MASTER ON
EVENT_TRACKER.SOURCE = SOURCE_MASTER.SOURCE)
INNER JOIN PART_EVENT_LINK ON
EVENT_TRACKER.EVENT_CD = PART_EVENT_LINK.EVENT_CD AND
EVENT_TRACKER.SOURCE = PART_EVENT_LINK.SOURCE AND
EVENT_TRACKER.PART_CD = PART_EVENT_LINK.PART_CD}
WHERE
SOURCE_MASTER.SOURCE_GRP = 'P_VS01' AND
PART_EVENT_LINK.HOT = 'PP' AND
EVENT_TRACKER.PART_CD <> 'OKV000' AND
EVENT_TRACKER.PRODN_DATE >= @PRODN_DATE_START AND
EVENT_TRACKER.PRODN_DATE <= @PRODN_DATE_END)
Don't worry about anything in the query except the last two lines where the variables are referenced. When I run this query, it takes about a minute to run.
Next query:
(SELECT COUNT(EVENT_TRACKER.EVENT_CD)
FROM
{ oj (EVENT_TRACKER INNER JOIN SOURCE_MASTER ON
EVENT_TRACKER.SOURCE = SOURCE_MASTER.SOURCE)
INNER JOIN PART_EVENT_LINK ON
EVENT_TRACKER.EVENT_CD = PART_EVENT_LINK.EVENT_CD AND
EVENT_TRACKER.SOURCE = PART_EVENT_LINK.SOURCE AND
EVENT_TRACKER.PART_CD = PART_EVENT_LINK.PART_CD}
WHERE
SOURCE_MASTER.SOURCE_GRP = 'P_VS01' AND
PART_EVENT_LINK.HOT = 'PP' AND
EVENT_TRACKER.PART_CD <> 'OKV000' AND
EVENT_TRACKER.PRODN_DATE >= '04/17/02' AND
EVENT_TRACKER.PRODN_DATE <= '04/17/02')
Notice there are no parameters, just the values in their place in the last two lines. The second query runs in about a second. How do I get the first one to run as fast as the second one? I have to have the parameters for my stored procedure....
Thanks in advance.
Query:
declare @PRODN_DATE_START datetime, @PRODN_DATE_END datetime
set @PRODN_DATE_START = '04/17/02'
set @PRODN_DATE_END = '04/17/02'
(SELECT COUNT(EVENT_TRACKER.EVENT_CD)
FROM
{ oj (EVENT_TRACKER INNER JOIN SOURCE_MASTER ON
EVENT_TRACKER.SOURCE = SOURCE_MASTER.SOURCE)
INNER JOIN PART_EVENT_LINK ON
EVENT_TRACKER.EVENT_CD = PART_EVENT_LINK.EVENT_CD AND
EVENT_TRACKER.SOURCE = PART_EVENT_LINK.SOURCE AND
EVENT_TRACKER.PART_CD = PART_EVENT_LINK.PART_CD}
WHERE
SOURCE_MASTER.SOURCE_GRP = 'P_VS01' AND
PART_EVENT_LINK.HOT = 'PP' AND
EVENT_TRACKER.PART_CD <> 'OKV000' AND
EVENT_TRACKER.PRODN_DATE >= @PRODN_DATE_START AND
EVENT_TRACKER.PRODN_DATE <= @PRODN_DATE_END)
Don't worry about anything in the query except the last two lines where the variables are referenced. When I run this query, it takes about a minute to run.
Next query:
(SELECT COUNT(EVENT_TRACKER.EVENT_CD)
FROM
{ oj (EVENT_TRACKER INNER JOIN SOURCE_MASTER ON
EVENT_TRACKER.SOURCE = SOURCE_MASTER.SOURCE)
INNER JOIN PART_EVENT_LINK ON
EVENT_TRACKER.EVENT_CD = PART_EVENT_LINK.EVENT_CD AND
EVENT_TRACKER.SOURCE = PART_EVENT_LINK.SOURCE AND
EVENT_TRACKER.PART_CD = PART_EVENT_LINK.PART_CD}
WHERE
SOURCE_MASTER.SOURCE_GRP = 'P_VS01' AND
PART_EVENT_LINK.HOT = 'PP' AND
EVENT_TRACKER.PART_CD <> 'OKV000' AND
EVENT_TRACKER.PRODN_DATE >= '04/17/02' AND
EVENT_TRACKER.PRODN_DATE <= '04/17/02')
Notice there are no parameters, just the values in their place in the last two lines. The second query runs in about a second. How do I get the first one to run as fast as the second one? I have to have the parameters for my stored procedure....
Thanks in advance.