Subject Re: [firebird-support] A complicated subquery slows down the main query
Author Dimitry Sibiryakov
On 9 Dec 2003 at 19:19, Maciek BOROWKA wrote:

>I have a problem with the performance of some of the queries I do.
>They are all basically of the same type:
>
>SELECT * from Atable WHERE AKey IN
>(select aKey
>from AnotherTable
>group by aKey
>having count(*) > 1)

I'd put this into SP. Something like this:

for select aKey from AnotherTable group by aKey having count(*)>1
into :varname do
begin
for select field1, field2, field3 from Atable where AKey=:varname
into :outparam1, :outparam2, :outparam3 do
begin
suspend;
end;
end;

SY, Dimitry Sibiryakov.