Subject Re: Access in asc and desc order, index twice?
Author Adam
--- In, Federico Tello Gentile
<fgentile@s...> wrote:
> 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"
> Both queries are done always one after the other in the same
> Should I index this table's year and month twice, once ascending and
> once descending to improve performance?

Yes it will improve performance but

> 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.

A reality check, at that rate of growth, it might be 5 years before
you get any measurable increase in performance. I would add both
indices though, as it wont be expensive to maintain them and it is
good practice to have appropriate indices to back up any queries you
plan on running. It may be 10 this month, in two years time, who knows
it may jump to 500 a month.