Subject min() and max() performance
Author jonesjeffreyr
can some one explain why you need am index sorted in descending order
for the max() function go create a plan that uses the index. the
same holds true for the min() function and ascending indexes.

for example if i have the following indexes

CREATE INDEX BY_TXNNMBR_A ON OFCFX(TXNNMBR)
CREATE DESC INDEX BY_TXNNMBR_D ON OFCFX(TXNNMBR)

when I do the query

SELECT MAX(TXNNMBR) FROM OFCFX

it uses the following plan

PLAN (OFCFX ORDER BY_TXNNMBR_D)

but if i drop the index BY_TXNNMBR_D the plan changes to

PLAN (OFCFX NATURAL)

shouldn't firebird be able to use the index BY_TXNNMBR_A to optimize
the query?

it just seems rather inefficient to have to maintain both a ascending
and descending index for both the MAX() and MIN() to optimize
properly.