patternModerate
Creating an index in both asc and desc directions
Viewed 0 times
creatingbothascdescandindexdirections
Problem
Over the past few weeks I've been raging against an old Firebird database. This database is crappy for all sorts of reasons, but one thing I noticed was that every single field of every single table has two indexes; each one with a single segment, one in
Apart from the wtf'ness of having an index for every field in every table, it got me thinking - is there any advantage for single-segment indexes to having two indexes with the same index segments, but one in
asc order and one in desc order.Apart from the wtf'ness of having an index for every field in every table, it got me thinking - is there any advantage for single-segment indexes to having two indexes with the same index segments, but one in
desc and one in asc? Is there anything to be gained, or would a modern DBMS simple use the asc index and start from the end and work its way backwards if required?Solution
I'd be surprised to hear of a modern database that can't do reverse order index scans.
- SQL Server certainly does and the backward scan is indicated in the execution plan.
- Firebird (search for backward in the page text).
- MySQL
Context
StackExchange Database Administrators Q#18208, answer score: 10
Revisions (0)
No revisions yet.