BUG #5000: Optimizer does not use function-based index for an order by - Mailing list pgsql-bugs

From Brian Ceccarelli
Subject BUG #5000: Optimizer does not use function-based index for an order by
Date
Msg-id 200908202030.n7KKUuNE034370@wwwmaster.postgresql.org
Whole thread Raw
Responses Re: BUG #5000: Optimizer does not use function-based index for an order by  (Greg Stark <gsstark@mit.edu>)
List pgsql-bugs
The following bug has been logged online:

Bug reference:      5000
Logged by:          Brian Ceccarelli
Email address:      ceccareb@talusmusic.com
PostgreSQL version: 8.2.13
Operating system:   Linux
Description:        Optimizer does not use function-based index for an order
by
Details:

Subject line says it all.
I have a function-based index on a large table.

select *
  from net32_product_def
 order by (f_squash_descr(descr::text))

create unique index net32_product_def_text_idx on net32_product_def (
f_squash_descr(descr) )

The explain plan says that Postgres always does a table scan instead of
using the index.   The table is 500,000 rows long, and the function
f_squash_descr() is a CPU-instensive operation.   What should come
instantly, takes 1 minute.

pgsql-bugs by date:

Previous
From: "Brian Ceccarelli"
Date:
Subject: BUG #4999: select 'a' < 'A' is true, but should be false . . .
Next
From: Greg Stark
Date:
Subject: Re: BUG #5000: Optimizer does not use function-based index for an order by