Subject Re: Subqueries and indexes
Author yoav112003
Hi

The performance is about the same as the original query. As in the
original query, according to the plan the index on 'ROWID' in table
'events' is not used (natural sort is used), and if I try to specify
it in a custom plan I get the error:

SQL Message : -284
index cannot be used in the specified plan

How can I force FB to use this index?

Thanks.

--- In firebird-support@yahoogroups.com, Milan Babuskov <milanb@...>
wrote:
>
> yoav112003 wrote:
> > I am trying to run the following query (FB 2 RC3):
> >
> > SELECT distinct ROWID FROM events
> > WHERE events.ROWID IN (
> >
> > SELECT DISTINCT DESTINATION.EVENTID FROM DESTINATION
> > WHERE ( (DESTINATION.IP ='158.125.73.220'))
> > )
>
> Try:
>
> SELECT distinct ROWID FROM events e
> WHERE EXISTS (
> SELECT 1
> FROM DESTINATION d
> WHERE d.IP ='158.125.73.220'
> AND d.EVENTID = e.ROWID)
>
> and tell us how it works.
>
> --
> Milan Babuskov
> http://swoes.blogspot.com/
> http://www.flamerobin.org
>