Re: Why LIMIT and OFFSET are commutative - Mailing list pgsql-general

From Lew
Subject Re: Why LIMIT and OFFSET are commutative
Date
Msg-id YfydndBaOsdNfNfanZ2dnUVZ_gWdnZ2d@comcast.com
Whole thread Raw
In response to Re: Why LIMIT and OFFSET are commutative  (Lew <lew@lwsc.ehost-services.com>)
List pgsql-general
Andrus wrote:
>> Under what interpretation would the results differ?
>
> Results must differ for easy creation of LinQ-PostgreSQL driver.
> If results are always the same , PostgreSQL should not allow to use both
> order of clauses.

Um, no, and your original post had nothing to do with LINQ.

My answer was only about SQL.

Your LINQ problems have to be solved in LINQ.

> Nicholas explains:
>
>    Assuming the ordering is the same on each of them (because Skip and Take
> make no sense without ordering, LINQ to SQL will create an order for you,
> which irritates me to no end, but that's a separate thread), they will
> produce different results.

Irrelevant.  The SQL definitions of these clauses is the SQL definition.  LINQ
is a separate issue.

Again, the *SQL* definition says, quoting the PG docs at
<http://www.postgresql.org/docs/8.2/interactive/queries-limit.html>
> If both OFFSET and LIMIT appear, then OFFSET rows are skipped
> *before starting to count the LIMIT rows that are returned.*
(emphasis added)

That's SQL, my friend.  OFFSET first, then LIMIT.  Irrespective of the order
in the query statement.  It is what it is.  SQL doesn't depend on LINQ for its
semantics.

--
Lew

pgsql-general by date:

Previous
From: Peter Bauer
Date:
Subject: System Load analyze
Next
From: "Amit"
Date:
Subject: Help Needed