Subject | Re: [ib-support] PLAN and stored procedure |
---|---|
Author | Svein Erling Tysvær |
Post date | 2002-08-16T10:12:11Z |
Hi Nils,
hence no index can be useful. Try rewriting to something like
SELECT DISTINCT Verzeichnislinks.AID
FROM Verzeichnislinks
WHERE EXISTS (SELECT 1 FROM CreateVidListe(12002) CVL WHERE CVL.VID =
Verzeichnislinks.VID)
or (possibly better)
SELECT DISTINCT Verzeichnislinks.AID
FROM Verzeichnislinks
JOIN CreateVidListe(12002) CVL ON CVL.VID = Verzeichnislinks.VID
Note that I don't use stored procedures very much and that there may be
some mistakes in my code.
to depend upon a value in your table (e.g. select Distinct
Verzeichnislinks.AID From Verzeichnislinks Where (Verzeichnislinks.VID in
(Select VID From CreateVidListe(Verzeichnislinks.AID)))), so it is a bit
more dynamic than what you need in your case. I think it would be desirable
if IB/FB was able to detect whether the result of a subselect was depending
upon the table being selected from, but currently I simply don't think it
can do that (it is not enough just to examine the subselect, the subselect
may have further subselects etc. so it may be more difficult to implement
than those of us not knowing the code believes).
HTH,
Set
>Select DistinctI think your subselect is executed once for every row in Verzeichnislinks.
> Verzeichnislinks.AID
> >From Verzeichnislinks
>Where
> (Verzeichnislinks.VID in (Select VID From CreateVidListe(12002)))
>
>(Stored procedure CreateVidListe(12002))
hence no index can be useful. Try rewriting to something like
SELECT DISTINCT Verzeichnislinks.AID
FROM Verzeichnislinks
WHERE EXISTS (SELECT 1 FROM CreateVidListe(12002) CVL WHERE CVL.VID =
Verzeichnislinks.VID)
or (possibly better)
SELECT DISTINCT Verzeichnislinks.AID
FROM Verzeichnislinks
JOIN CreateVidListe(12002) CVL ON CVL.VID = Verzeichnislinks.VID
Note that I don't use stored procedures very much and that there may be
some mistakes in my code.
>* Have IB problems with Stored Procedures used in a select statement andNo, the problem is with the subselect in your IN clause.
>the query optimizer?
>* What must I do if I want that Query using a stored produre to fill theI don't think this is possible - in theory it is possible for the subselect
>IN statemend also use a index for the Verzeichnislinks table?
to depend upon a value in your table (e.g. select Distinct
Verzeichnislinks.AID From Verzeichnislinks Where (Verzeichnislinks.VID in
(Select VID From CreateVidListe(Verzeichnislinks.AID)))), so it is a bit
more dynamic than what you need in your case. I think it would be desirable
if IB/FB was able to detect whether the result of a subselect was depending
upon the table being selected from, but currently I simply don't think it
can do that (it is not enough just to examine the subselect, the subselect
may have further subselects etc. so it may be more difficult to implement
than those of us not knowing the code believes).
HTH,
Set