Subject | Re: [firebird-support] query optimization- MAX() from .. WHERE |
---|---|
Author | Helen Borrie |
Post date | 2010-08-18T10:06:37Z |
At 09:07 PM 18/08/2010, you wrote:
./heLen
>HiTake FOREIGN_KEY out of that index!
>I've got table similar to the following example:
>
>CREATE TABLE TEST_TAB (
> ID INTEGER NOT NULL PRIMARY KEY,
> NUMER INTEGER,
> FOREIGN_KEY INTEGER);
>CREATE DESCENDING INDEX TEST_TAB_IDX1 ON TEST_TAB (FOREIGN_KEY, NUMER);
>
>and query like this:
>
>select max(t.numer)
> from test_tab t
> where t.foreign_key = :some_value
>
>PLAN (T INDEX (TEST_TAB_IDX1))
>
>So it uses proper index but Performance Analysis shows lot of reads (as much as count() where foreign_key = :some_value).
>
>Is it any way to improve this query performance
./heLen