Re: Backwards index scan - Mailing list pgsql-general

From Stephan Szabo
Subject Re: Backwards index scan
Date
Msg-id 20030707144149.H81868-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Backwards index scan  (Dmitry Tkach <dmitry@openratings.com>)
Responses Re: Backwards index scan  (Dmitry Tkach <dmitry@openratings.com>)
Re: Backwards index scan  (Dmitry Tkach <dmitry@openratings.com>)
List pgsql-general
On Mon, 7 Jul 2003, Dmitry Tkach wrote:

> I understand that with the generic approach to operators in postgres it
> is, probably, not very feasible to try and teach _bt_first () to handle
> this situation automatically (it would need to know how to get
> next/previous value for every indexable type)... I guess, that could be
> done by adding another kind of strategy to pg_amop for example...
> Another way to work around this would be to allow ordering spec to be a
> part of CREATE INDEX (I know, that informix does that for example) - so
> that, I could do
> create index huge_table_idx on huge_table (x, y desc);
> ... and then select * from huge_table where x=10 order x, y desc;
> would not require a backwards scan to begin with.
>
> Can something like this be done? What do you think?

If you make an opclass that orders in the reverse order you can use that
opclass in creating the index (which effectively can give you an index
like x, y desc by using the new opclass on y).  There was some talk
recently about whether we should provide such opclasses as builtins or
contrib items.


pgsql-general by date:

Previous
From: Dmitry Tkach
Date:
Subject: Backwards index scan
Next
From: Dmitry Tkach
Date:
Subject: Re: Backwards index scan