Re: Variable LIMIT and OFFSET in SELECTs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sam Mason <sam(at)samason(dot)me(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Variable LIMIT and OFFSET in SELECTs
Date: 2007-11-15 17:25:54
Message-ID: 5387.1195147554@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sam Mason <sam(at)samason(dot)me(dot)uk> writes:
> In relational algebra terms, try thinking about what would happen if you
> did something like:

> SELECT * FROM foo LIMIT val;

> Where the table foo has more than one row (and val had different values
> for each row). Which row would the database use? I believe these are
> the semantics Trevor was referring to.

Exactly: if the numbers are coming from within the query then there is
no guarantee that there's a unique value to use. The numbers can be
variable so long as they come from "outside" the query and so are fixed
over any one query execution. That includes the case of a subselect
getting its limit from the outer query, for instance ... but not what
the OP was trying to do.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2007-11-15 17:27:07 Re: [GENERAL] "global/pg_control": Permission denied
Previous Message Steve Atkins 2007-11-15 17:20:33 Re: PLpgsql debugger question