Subject Re: [firebird-support] slow order by performance on a view
Author Mark Rotteveel
On 24-7-2013 06:22, ttt_dev wrote:
> hi, thanks for any help with this...
>
> i need to select the first x records from a view ordered by ID descending.
>
> when the view does not contain an ORDER BY statement then the query is rapid. however when i put an ORDER BY statement in then the query becomes extremely slow (from 1 sec to nearly 1 min).
>
> i tried to add a descending index on the docs_search_terms table then recomputed the indexes afterwards with little effect.
>
> i will paste the SQL and the plan below. i would be grateful for any assistance with this. thanks.
>
> Example Sql
> ---
>
> select first 500 * from VW_DOCS_BY_SEARCH_TERMS_LIST where terms containing 'invoice';

What happens if you remove the ORDER BY from the view and add it to the
query itself?

Mark
--
Mark Rotteveel