Re: BUG #13790: last row of limit/offset result produces duplicates

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: pbelbin(at)gmail(dot)com
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #13790: last row of limit/offset result produces duplicates
Date: 2015-12-03 19:43:44
Message-ID: CAKFQuwatYOTvMuCrZQ3N9z16A9FYoeY5CtRq9XiLwgyhZ4dG_g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Dec 2, 2015 at 2:02 PM, <pbelbin(at)gmail(dot)com> wrote:

> select * from demo1 order by code limit 5 offset 10
>
> 18;CHCG;240
> 19;CHCG;248
> 20;CHCG;250
> 14;CHCG;224
> 10;CHCG;216
>
> and then:
>
> select * from demo1 order by code limit 5 offset 20
>
> 28;CHCG;289
> 29;CHCG;301
> 30;CHCG;302
> 14;CHCG;224
> 10;CHCG;216
>
>
> the last row of the two result sets above is the same row!
>
> changing the sorting so that it includes the match column appears to avoid
> the issue, but, this is a bug. each row should only appear once if the
> limit/offset values are looking at different portions of the result that
> would be produced without the limit/offset options
> ​.
>

I'm sorry but no, that is not how this works. The two queries are
independent and if you fail to adequately specify the ORDER BY the fault is
yours, not the system's.

David J.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2015-12-03 20:11:08 Re: BUG #13790: last row of limit/offset result produces duplicates
Previous Message Paul Moore 2015-12-03 17:02:31 Re: BUG #13788: compile error in generic_msvc.h