Subject Re: Compound Index
Author pokka_chi
--- In firebird-support@yahoogroups.com, "Ivan Prenosil"
<Ivan.Prenosil@...> wrote:

> It is not question whether it helps much or not. Without ORDER BY
> the query does not make sense at all.

I've added the order by clause and retried it with IBOConsole to check
the statistics.

The query is SELECT FIRST 10 * FROM MY_TABLE WHERE COLUMN1 > 100 ORDER
BY COLUMN1, COLUMN2

The table has the index MY_INDEX on (COLUMN1, COLUMN2).
Total number of records in the table = 100,000.
Size of one record is approx. 3000 bytes.
Number of rows with (Column1 > 100) is 89901.

The statistics returned is as follows:
Execution Time: 28.0766
Prepare Time: 0.0094
Reads: 90420
Write: 5
Plan: PLAN (MY_TABLE ORDER MY_INDEX INDEX (MY_INDEX))
Rows affected: 89901

PK