Subject | RE: [firebird-support] Slow query using stored procedure |
---|---|
Author | Svein Erling Tysvær |
Post date | 2013-02-19T09:23:36Z |
>Hi Svein,thanks a lot for your help!Well, the added requirement makes the query slightly different, John, but changing it to a LEFT JOIN is simple:
>I also need to add one condition to my query,but I don't know how to do it using your script,so
>my new query:
>
> SELECT a.date,a.id FROM mytable1 a WHERE a.year=2013
> AND (a.month=1 OR (A.NUMB
> IN (SELECT DISTINCT X.NUMB FROM PR_GET_SOLD(2013,1) X ) ))
>
>so adding this I think I can't use join as you suggested in your script
with ExecuteMeOnce as
(SELECT DISTINCT numb FROM PR_GET_SOLD(2013,1))
SELECT a.date, a.id
FROM mytable1 a
LEFT JOIN ExecuteMeOnce x ON a.numb = x.numb
WHERE a.year = 2013
AND (a.month = 1
OR x.numb IS NOT NULL)
I'm curious to learn whether this does improve the speed or if it still takes two minutes, so please report back.
HTH,
Set