Subject PLAN and stored procedure
Author Nils Boedeker
Hi

in a query (IBX 4.52 and IB 6) I use a stored procedure that fills the
values of a Select "IN" Statement:

1) Example:
---------------------------------------------------------------------

Select Distinct
Verzeichnislinks.AID
>From Verzeichnislinks
Where
(Verzeichnislinks.VID in (Select VID From CreateVidListe(12002)))

(Stored procedure CreateVidListe(12002))

--------------------------------------------------------------------

If I start this query the Plan statemment is:
-------------------------------------------------

PLAN (VERZEICHNIS ORDER RDB$PRIMARY9)
PLAN SORT ((VERZEICHNISLINKS NATURAL))

This means that the "IN" Statement for the verzeichnislinks table do not
use an index.


Example 2)
If I use query without stored procedure and where the IN statemend
filled by hand
---------------------------------------------------------------------

Select Distinct
Verzeichnislinks.AID
>From Verzeichnislinks
Where
(Verzeichnislinks.VID in (12002,1536,1571,1572))

---------------------------------------------------------------------

The query plan is:
---------------------------------------------------------------------

PLAN SORT ((VERZEICHNISLINKS INDEX
(RDB$PRIMARY12,RDB$FOREIGN13,RDB$PRIMARY12,RDB$FOREIGN13,RDB$PRIMARY12,RDB$FOREIGN13,RDB$PRIMARY12,RDB$FOREIGN13)))

---------------------------------------------------------------------

This means for selection in the "VERZEICHNISLINKS" the correct index
have been used.

Question:

* Have IB problems with Stored Procedures used in a select statement and
the query optimizer?

* What must I do if I want that Query using a stored produre to fill the
IN statemend also use a index for the Verzeichnislinks table?

Thank you a lot for your help...

with best regards

Nils