Subject Re: [firebird-support] Index Strategy
Author Ann Harrison
Stephane,


>
> I have a problem that i thing any web site can have !
>
> Let say i m a car dealer WebSite and want to permit user to search my
> zillions car Firebrd database
>
> Typycal search will be
>
> SELECT
> FIRST 100 SKIP 0,
> *
> FOR
> CAR
> Where
> NAME = 'BMW' AND
> LOCATION = 'NEW YORK CITY' AND
> PRICE > 30000 AND
> PRICE < 40000 AND
> YEAR > 2004
> ORDER BY CREATION_DATE DESC
>
>
> So here what index strategy to choose ?
>
> INDEX (LOCATION, NAME, PRICE) ?
> INDEX (LOCATION, NAME, YEAR) ?
> INDEX (LOCATION, NAME, CREATION_DATE) ?
> INDEX (PRICE) ?
> INDEX (YEAR) ?
> INDEX (CREATION_DATE) ?

With Firebird, the choices are simpler, though not better. In the absence of the FIRST and ORDER clauses, it will use an index. on Price, plus an index on Location, plus an index on Name, plus An index on Year. With those clauses, it can use only Creation_Date because it will emulate the sort with an index walk, and can walk only one index.

Good luck,

Ann