Subject Re: [firebird-support] Indexes automatically used?
Author Alexandre Benson Smith
Clay,

Clay Shannon wrote:

>I've added several indexes to my database. Do these take effect
>automatically when queries are run, or do I have to activate the indexes in
>my Delphi code before calling the stored procs that query the db?
>
>
>
Nothing to do on the Delphi code, the optimizer should use an index if
it's think it should.

Remember, not all indices are good !

>
>
>Also, I have one query that does this:
>
>
>
>Order by sort_order, empno, shiftdate, created desc
>
>
Indices are better to filter the result set than to order it...

If the engine chooses to use an index for an ordered navigational scan
the first row will prompts quickly, but the total time tends to be
greater than if it reads the page in natural order and then sort in memory.

A sort in memory is extremelly fast !

Think for indices for the where clause not the order clause. As always
there are exceptions for this rule !

>
>
>Should I have four different indexes to speed up this query, or one
>composite index?
>
>
>
>Clay Shannon,
>
>Dimension 4 Software
>
>

see you !

--

Alexandre Benson Smith
Development
THOR Software e Comercial Ltda.
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br



--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.4/66 - Release Date: 09/08/2005