Re: RLS creates inaccurate limit and offset results

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: mike(at)mikebrancato(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: RLS creates inaccurate limit and offset results
Date: 2025-11-12 18:20:07
Message-ID: 182B8CBD-3A96-434F-A4BF-6270DA11A44D@thebuild.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

> On Nov 11, 2025, at 14:46, mike(at)mikebrancato(dot)com wrote:
> If I understand the documentation (https://www.postgresql.org/docs/current/queries-limit.html) inconsistent results for different LIMIT / OFFSET values is only a known issue when selecting different subsets of data.

The documentation could perhaps be better worded, but PostgreSQL makes no guarantee of the order of a result set in absence of an ORDER BY clause over that particular result set. Since the ordering can't be guaranteed, which particular subset you get from LIMIT and OFFSET is not guaranteed either.

Again, this has nothing to do with RLS in particular. The more complex the query and the more steps a result set has to go through from disk ordering to result set ordering, the more likely it is to see inconsistent results, but it's never guaranteed in any case.

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2025-11-12 18:27:01 Re: RLS creates inaccurate limit and offset results
Previous Message Michael Paquier 2025-11-12 08:15:15 Re: BUG #19095: Test if function exit() is used fail when linked static