Subject | RE: [firebird-support] Hints? |
---|---|
Author | Alan McDonald |
Post date | 2005-04-15T23:36:55Z |
> Does Firebird support table or join hints? I can't get Firebirdyou can declare plans but in this instance your query could be dramatically
> to use the
> appropriate index when returning results from a subquery even when there
> exists an index on the joined column. My query is fairly
> complex, but even
> when I break it down to the following, it won't use the index on ID2 of
> table A. Table A contains tens of thousands of rows.
>
>
> SELECT A.NAME
> FROM A
> WHERE A.ID2 IN
> (SELECT B.ID2
> FROM B, C
> WHERE B.ID1 = C.ID1
> AND C.NAME = 'FOO')
>
> Any suggestions other than rewriting the query?
>
>
> [Non-text portions of this message have been removed]
improved anyway by using join syntax rather than the WHERE IN and WHERE
syntax.
WHERE IN should only be used where you know the IN clause will return are
small resultset (or that's the rule I follow)
Alan
SELECT A.NAME FROM A JOIN B ON A.ID2=B.ID2 JOIN C ON B.ID1=C.ID1
WHERE C.NAME='FOO'