Subject | Re: [firebird-support] How to improve Firebird performance on a large table? |
---|---|
Author | Ann Harrison |
Post date | 2013-03-05T21:52:55Z |
On Mon, Mar 4, 2013 at 2:14 AM, Alan J Davies <
Alan.Davies@...> wrote:
there's a compound ascending index on the combination of field_value and
field_value2. Without that index, the query will first find all the
records that match the where conditions, sort them return the first 20 and
throw out the rest. If you had to scan to find the next 20, it would do
the same, but throw out the first 20, return the next 20 and throw out the
rest. And to get the next twenty, it again retrieves and sorts all
qualifying records, and throw out all but 20.
Good luck,
Ann
[Non-text portions of this message have been removed]
Alan.Davies@...> wrote:
>That version of the query is likely to have performance problems unless
>
> What do you want to do with the returned data? View it? Can you handle
> more than 20 records at a time on your screen?
>
> select first 20 field_value,field_value1,field_value2,field_value100
> from table
> where field_value = 1 (and field_value2=2)
> order by field_value,field_value2
>
there's a compound ascending index on the combination of field_value and
field_value2. Without that index, the query will first find all the
records that match the where conditions, sort them return the first 20 and
throw out the rest. If you had to scan to find the next 20, it would do
the same, but throw out the first 20, return the next 20 and throw out the
rest. And to get the next twenty, it again retrieves and sorts all
qualifying records, and throw out all but 20.
Good luck,
Ann
[Non-text portions of this message have been removed]