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

From Tom Lane
Subject Re: Does anybody use ORDER BY x USING y?
Date
Msg-id 18053.1127100868@sss.pgh.pa.us
Whole thread Raw
In response to Re: Does anybody use ORDER BY x USING y?  (Greg Stark <gsstark@mit.edu>)
Responses Re: Does anybody use ORDER BY x USING y?
List pgsql-hackers
Greg Stark <gsstark@mit.edu> writes:
> Tom Lane <tgl@sss.pgh.pa.us> writes:
>> That would be an extremely bad idea, because it would immediately remove
>> index scans as one way to meet an ORDER BY.  

> Well couldn't the index scan be taught to go fetch the NULLs in a separate
> traversal? 

(1) IS NULL is not an indexable operation, so no, not without
significant overhaul of the index AM API.

(2) This propagates a problem that is specific to orderable indexes (ie
btree) into code that is generic to all indexes, and thus creates the
problem of how do you deal with specifying NULL ordering without any
definition of ordering for non-NULLs.

(3) You still have to invent a mechanism to define whether you want
nulls first or last ... and make sure that that mechanism works for
plans that use explicit SORT steps as well as those that use index
scans.
        regards, tom lane


pgsql-hackers by date:

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