Re: BUG #16548: Order by on array element giving disparity in result - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #16548: Order by on array element giving disparity in result
Date
Msg-id 825164.1595340915@sss.pgh.pa.us
Whole thread Raw
In response to BUG #16548: Order by on array element giving disparity in result  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
PG Bug reporting form <noreply@postgresql.org> writes:
> postgres=# select * from bint order by a[2] desc limit 5;
>        a       
> ---------------
>  {14}
>  {10}
>  {14}
>  {10,14,10,10} 
>  {10,14,14,14} 
> (5 rows)

You failed to say what you think is a bug here, but I'm going
to guess that you're unhappy that this is not the same as
the first five rows of the not-limited sort output.  We do not
consider that a bug, because the sort key is very underspecified
here.  The first three rows share the same sort key (null) and
can legitimately come out in any order.  Likewise, rows with
a[2] = 14 can come out in any order.

The underlying implementation reason why it acts differently
is that sort-with-limit uses a different sorting method.

            regards, tom lane



pgsql-bugs by date:

Previous
From: PG Bug reporting form
Date:
Subject: BUG #16549: "CASE" not work properly , the function works properly on PostgreSQL 9.6.8
Next
From: "David G. Johnston"
Date:
Subject: Re: Bug - 11.8