Re: any way for ORDER BY x to imply NULLS FIRST in 8.3?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: any way for ORDER BY x to imply NULLS FIRST in 8.3?
Дата
Msg-id 19134.1194360517@sss.pgh.pa.us
обсуждение исходный текст
Ответ на any way for ORDER BY x to imply NULLS FIRST in 8.3?  (rihad <rihad@mail.ru>)
Ответы Re: any way for ORDER BY x to imply NULLS FIRST in 8.3?
Список pgsql-general
rihad <rihad@mail.ru> writes:
> Is there any way to "hardcode" the NULL handling in an index (as  per
> http://www.postgresql.org/docs/8.3/static/indexes-ordering.html) so that
> SELECT * FROM t ORDER BY foo automatically implies NULLS FIRST (and,
> similarly so that SELECT * FROM t ORDER BY foo DESC automatically
> implies NULLS LAST)?

No.  This is not a question of how indexes behave, it is a question of
which semantics the parser ascribes to an undecorated ORDER BY request.

> Thing is, I'm using PHP Symfony/Propel to generate
> their SQL and have no easy way to influence how they do so.

SQL99 section 14.1 <declare cursor> saith:

              ... Whether
              a sort key value that is null is considered greater or less
              than a non-null value is implementation-defined, but all sort
              key values that are null shall either be considered greater
              than all non-null values or be considered less than all non-
              null values. ...

Essentially the same text appears in SQL2003.  Any application that
depends on one particular choice here is therefore broken, or at least
has chosen to work with only about half of the DBMSes in the world.

            regards, tom lane

В списке pgsql-general по дате отправления:

Предыдущее
От: SHARMILA JOTHIRAJAH
Дата:
Сообщение: Re: Postgresql simple query performance question
Следующее
От: "Scott Marlowe"
Дата:
Сообщение: Re: Selecting all but a few fields in a query