The first to lines of the query alone give a result in ~3 seconds: select first(8) ID from TBL_TEST where ID not in (select first(2) ID from TBL_TEST order by ID desc)
The result are just 8 entries. Sorting those 3 entries should then take no time at all, right? But by adding the last "order by" it just takes forever... select first(8) ID from TBL_TEST where ID not in (select first(2) ID from TBL_TEST order by ID desc) order by ID desc Any ideas? On Fri, Jan 24, 2020 at 2:39 PM Dimitry Sibiryakov s...@ibphoenix.com [firebird-support] <firebird-support@yahoogroups.com> wrote: > 24.01.2020 14:29, Matthias Winkler spmm...@gmail.com [firebird-support] > wrote: > > I see the very same issue with firebird 3.0.4. Any ideas? > > You made nested loop on 18000*18000 records with sorting on each > itaretion. It cannot > be fast. > > > -- > WBR, SD. > > > ------------------------------------ > > ------------------------------------ > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > > Visit http://www.firebirdsql.org and click the Documentation item > on the main (top) menu. Try FAQ and other links from the left-side menu > there. > > Also search the knowledgebases at > http://www.ibphoenix.com/resources/documents/ > > ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > ------------------------------------ > > Yahoo Groups Links > > > >