Re: additional message to the bug #7499

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: Denis Kolesnik <lirex(dot)software(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: additional message to the bug #7499
Date: 2012-08-23 01:57:57
Message-ID: 50358E25.9040105@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2012-08-23 02:24:11 Re: BUG #4958: Stats collector hung on WaitForMultipleObjectsEx while attempting to recv a datagram
Previous Message Tom Lane 2012-08-23 01:26:27 Re: bug #7499 additional comments