From: Craig Ringer <ringerc@ringerc.id.au>
To: Denis Kolesnik <lirex.software@gmail.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: additional message to the bug #7499
Date: Thu, 23 Aug 2012 09:57:57 +0800
Message-ID: <50358E25.9040105@ringerc.id.au> (raw)
In-Reply-To: <CAHYNDb8+t61Y=AtrFnc29whz8tV5Oxu357cBgvtBcJas73diAg@mail.gmail.com>
References: <CAHYNDb8+t61Y=AtrFnc29whz8tV5Oxu357cBgvtBcJas73diAg@mail.gmail.com>
On 08/22/2012 08:36 AM, Denis Kolesnik wrote:
> I have now VERY strong argument to consider it is as a bug:
>
> if there a understandable for SQL language sequence which sorts
> in other fashion when adding "LIMIT".
Underspecified sorts can have unstable results, that's allowed by the
spec and is a reasonable performance optimisation. If you want stable
sorts you have to provide a fully defined ordering.
To say this is a bug is a bit like saying that undefined behaviour in C
is a bug. It isn't, the language and compiler are giving you what
they're supposed to, just not what you want.
http://en.wikipedia.org/wiki/Undefined_behavior
Unstable sorts are a common optimisation
http://en.wikipedia.org/wiki/Sorting_algorithm#Stability
and a very useful one. Not allowing Pg to use unstable sorts, or use
different sorts for different query plans, would slow correct queries
down to make an incorrect query like yours run how you expect.
--
Craig Ringer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: ringerc@ringerc.id.au, lirex.software@gmail.com
Subject: Re: additional message to the bug #7499
In-Reply-To: <50358E25.9040105@ringerc.id.au>
References: <CAHYNDb8+t61Y=AtrFnc29whz8tV5Oxu357cBgvtBcJas73diAg@mail.gmail.com> <50358E25.9040105@ringerc.id.au>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox