Re: Does anybody use ORDER BY x USING y? - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Does anybody use ORDER BY x USING y?
Date
Msg-id 87br2pozbi.fsf@stark.xeocode.com
Whole thread Raw
In response to Re: Does anybody use ORDER BY x USING y?  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: Does anybody use ORDER BY x USING y?
List pgsql-hackers
Martijn van Oosterhout <kleptog@svana.org> writes:

> On Sun, Sep 18, 2005 at 11:23:01PM -0400, Tom Lane wrote:
> <snip>
> > class families" to relate opclasses for different datatypes.  Basically
> > I'd like to solve most of these issues by constructing a new layer atop
> > opclasses, not by deciding that an opclass doesn't convey the full story
> > about the behavior of an index column.

The thing is that these opclasses you're describing are closely related. It
ought to be possible to use a single index to produce results in any of the
four orders you describe.

> Where I'm currently going is creating a table of COLLATE orders. These
> collate orders would refer to operator classes but "tweak" them. For
> example, things like:
> 
> - Sort ascending or descending (descending reverses the bt*cmp test)
> - NULLs first or last
> - Locale for text types
> - etc

These aren't all related in the same way. While it obviously isn't hard to
produce results ascending or descending, and it shouldn't be hard to produce
NULLs first or last regardless of where they appear in the index, it would be
utterly impossible to use an index built with the wrong locale collation.

-- 
greg



pgsql-hackers by date:

Previous
From: "Magnus Hagander"
Date:
Subject: Re: Beta2 Wrap Up ...
Next
From: Tom Lane
Date:
Subject: Re: Does anybody use ORDER BY x USING y?