Hi -
I've found that the H2 database can use an index to sort query
results, if the index column (or columns) are used properly in the
query's filter conditions.  However, it appears that specifying the
reverse order in the query (asc or desc) causes H2 to not use the
index for the sort, even though logically it could.

For a simple example:

create table address (street varchar, state varchar, zip int);
create index address_zip on address(zip asc) ;

explain select * from address where zip>0 order by zip;
=> sorted, as expected.

explain select * from address where zip>0 order by zip desc
=> not sorted, but could be sorted using the index in reverse.

Is this the expected behavior of H2, or is there something that could
be done to allow H2 to use the index for sorting in this case?

thanks!
-phil

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to