Subject Re: [ib-support] Re: using inclusive indices
Author Raymond Kennington
mikeevteev wrote:
>
> Hi!
>
> Table is ... just a table. Nothing special, just a lot of char fields.
> Main point is it has index, lets say on field named field_a.
>
> Query is stupid of cource: select field_a from table
>

It is necessary to specify a WHERE clause or ORDER BY clause in order to give the optimiser a reason to provide a
specific sequence.

SELECT Field_A FROM TheTable
ORDER BY Field_A

> I just guess that reading index is cheaper then reading all data pages
> in that case, becouse index cover all fields in query.
> But optimizer select plan with natural.
>
As you didn't specify that order mattered, the query returns the result in the fastest possible way.

It had indeed optimised your query! :)

> Another question related to optimazer.
> Table is same.
> Query select field_a from table
> Optimizer plan SORT(table NATURAL).
>
> Why SORT? Here is index already. All fields is covered!

This indicates that no order is specified, i.e. not sorted.
--
Raymond Kennington
Programming Solutions
W2W Team B