Subject Re: [firebird-support] Access in asc and desc order, index twice?
Author Martijn Tonies

> To get the installments to pay in secuential order I have to query
> sorting by year asc and month asc
> But to get the last payed installemnt I have to query by year desc and
> month desc using a "select first 1"

If there's no WHERE clause, a "descending" index could surely help.

A "desc" ORDER BY cannot use an ascending index.

> Both queries are done always one after the other in the same transaction.
> Should I index this table's year and month twice, once ascending and
> once descending to improve performance?
> This particlar table will not grow a lot. I expect less than 10 new
> records a month. Occationally some newly added record could be deleted
> by the user.
> This runs in FB 1.5.1, but I will move to FB 2 as soon as it is stable
> (you know FB 2 come with a lot of nice features and improvements).

With regards,

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Upscene Productions
Database development questions? Check the forum!