Subject Re: [ib-support] Plan query
Author Svein Erling Tysvær
Amrita,
I guess the main improvement to your query would be to use EXISTS rather
than IN, e.g. change

TRAF_ORG.SECTOR IN (SELECT INDEXLIST FROM GETSELECTEDINDEX(:SECTORV , 3))

to

EXISTS(SELECT 1 FROM GETSELECTEDINDEX(:SECTORV , 3) WHERE INDEXLIST =
TRAF_ORG.SECTOR)

and do the same for FA.

Another thing that I do not understand is why you join on that many fields.
Have you considered storing BSC, BTS, SECTOR, FA, PMDATE and PMHOUR in a
separate table and then just store the primary key of this new table in
TRAF_TER and TRAF_ORG? Don't think it will make much of a difference though.

I don't see what cascadeid is doing in this procedure at all and don't see
why you want it to execute last (in general, it is a good idea to have the
most restricting table first in the query plan).

Set