Subject | Re: Firebird Indexes |
---|---|
Author | Svein Erling Tysvær |
Post date | 2005-06-24T08:52:58Z |
Sorry for answering before properly reading the question...
No, a DESCending index cannot be used with an ASCending ORDER BY. You
need two separate indexes if you want to index the field both
ASCending and DESCending. Though note that too many indexes can be as
bad as too few indexes, create only those that are likely to be
selective and useful.
Set
No, a DESCending index cannot be used with an ASCending ORDER BY. You
need two separate indexes if you want to index the field both
ASCending and DESCending. Though note that too many indexes can be as
bad as too few indexes, create only those that are likely to be
selective and useful.
Set
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær wrote:
> Hello Adrian and welcome to Firebird!
>
> Firebird indexes are unidirectional, hence an ASCending index (the
> default) is completely different from a DESCending index. Regarding
> your query, I would expect the index to be used for sorting (i.e.
> PLAN SORT), but not for selection - simply since you do not include
> any WHERE clause to reduce the number of rows returned. Another
> question is how many records does the table contain? I don't know
> how smart the optimizer has become, but in general indexes will not
> be very useful if the table is empty or only contains a handfull of
> records.
>
> HTH,
> Set
>
> --- In firebird-support@yahoogroups.com, "Adrian Libotean" wrote:
> > Hello,
> >
> > I am new to Firebird SQL and I'm trying to develop a small
> > application with it.
> >
> > Using IBExpert and looking at the Plan Analyzer I've noticed that
> > using a select that looks like this: SELECT * FROM <table> ORDER
> > BY <field> ASC; will not use the existing descending index on
> > <field>. I found this weird because in other DB systems that I've
> > used if I create an index on <field> it will be used for both ASC
> > and DESC orders. Maybe I'm doing something wrong, can anyone help
> > me ?