While reading the Tuning Derby manual, I was surprised to find out that Derby 
won't use an available ascending-order index to do a descending-order ORDER BY:

   Think about index order:

   Derby allows you to create index columns in descending order in addition
   to creating them in ascending order, the default. Descending indexes
   provide performance benefits for the following kinds of queries that
   require sorting data in descending order.  To ensure performance benefits,
   verify that the descending index is being used. See Analyzing statement
   execution for information on how to do this.

I now know why some of my queries are slow, which is a good thing.  But it 
looks like I may have to add a second index in order to make the application 
able to present results ordered in either direction.

I couldn't find an open JIRA entry for enhancing Derby to make using of 
opposite-ordered indexes when doing ORDER BY.  Did I miss an existing one, 
should I add a new one, or is this impossible for some reason?

Reply via email to