Subject | RE: [firebird-support] Use of indexes |
---|---|
Author | Leyne, Sean |
Post date | 2011-12-27T19:19:04Z |
Tom,
Remember that even if the engine uses indexes to identify target rows, due to the multi-generational architecture/MVCC, the engine still reads the rows to confirm that the rows have the defined values. So, the engine decided that evaluating the company name value at this stage would provide the best query performance.
Sean
> Can anyone explain why FB uses all 3 in the OR query yet only 2 in the ANDThe engine looked at the selectivity value of the available indexes and decided that these 2 indexes provided the best outcome.
> query (See definitions below)?
> select * from target
> where
> upper(company) starting with 'A' and
> upper(firstname) starting with 'B' and
> upper(lastname) starting with 'C'
>
> PLAN (TARGET INDEX (I_TARGET_LASTNAME, I_TARGET_FORENAME))
Remember that even if the engine uses indexes to identify target rows, due to the multi-generational architecture/MVCC, the engine still reads the rows to confirm that the rows have the defined values. So, the engine decided that evaluating the company name value at this stage would provide the best query performance.
Sean