Subject | Re: [firebird-support] Optimizing subquery in WHERE .. |
---|---|
Author | Douglas Tosi |
Post date | 2009-02-10T14:18:05Z |
On Tue, Feb 10, 2009 at 11:48 AM, Harriv <harriv@...> wrote:
select field1
from table1
inner join (SELECT first 2 fieldA from table2 where fieldB = 1) t2 on
t2.fieldA=table1.field2
This should be faster if fields table1.fieldA and table2.fieldB are indexed.
hth,
--
Douglas Tosi
www.sinatica.com
> However I'd like to have subquery on where:Just guessing, but try:
> SELECT field1
> FROM table1
> where field2 in (SELECT first 2 fieldA from table2 where fieldB = 1)
select field1
from table1
inner join (SELECT first 2 fieldA from table2 where fieldB = 1) t2 on
t2.fieldA=table1.field2
This should be faster if fields table1.fieldA and table2.fieldB are indexed.
hth,
--
Douglas Tosi
www.sinatica.com