Subject | Re: [firebird-support] Composite index question |
---|---|
Author | Ivan Prenosil |
Post date | 2007-05-04T08:47:18Z |
> CREATE TABLE T (Foo VARCHAR(20), Bar INTEGER);Right, DESC can't be specified for individual fields.
>
> SELECT * FROM T
> ORDER BY Foo DESC, Bar
>
> How can I create an index for this query? (yes, I want that Foos are
> descending order and Bars are ascending order)
>
> CREATE INDEX IDX_1 ON T (Foo DESC, Bar)
>
> Statement failed. :(
> But,Right, if the index should be used for ordering, then single index
>
> CREATE INDEX IDX_1 ON T (Foo DESC)
> CREATE INDEX IDX_2 ON T (Bar)
>
> Statements are OK, but the query is don`t use these indexes. :(
must exist for _all_ fields in ORDER BY clause.
The only workaround I can think of is to store values in Bar with
changed sign.
Ivan
http://www.volny.cz/iprenosil/interbase/