Re: BUG #16548: Order by on array element giving disparity in result

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: manvendra2525(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16548: Order by on array element giving disparity in result
Date: 2020-07-21 14:15:15
Message-ID: 825164.1595340915@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2020-07-21 14:18:23 Re: Bug - 11.8
Previous Message PG Bug reporting form 2020-07-21 13:55:48 BUG #16549: "CASE" not work properly , the function works properly on PostgreSQL 9.6.8