Re: [HACKERS] SELECT ... LIMIT (trial implementation) - Mailing list pgsql-hackers

From Oleg Bartunov
Subject Re: [HACKERS] SELECT ... LIMIT (trial implementation)
Date
Msg-id Pine.GSO.3.96.SK.981018213213.17519C-100000@ra
Whole thread Raw
In response to Re: [HACKERS] SELECT ... LIMIT (trial implementation)  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [HACKERS] SELECT ... LIMIT (trial implementation)
List pgsql-hackers
On Sun, 18 Oct 1998, Tom Lane wrote:

> Date: Sun, 18 Oct 1998 12:04:49 -0400
> From: Tom Lane <tgl@sss.pgh.pa.us>
> To: Bruce Momjian <maillist@candle.pha.pa.us>
> Cc: pgsql-hackers@postgreSQL.org
> Subject: Re: [HACKERS] SELECT ... LIMIT (trial implementation)
>
> Bruce Momjian <maillist@candle.pha.pa.us> writes:
> > What if someone wants the rows from 500 to the end.  Should we allow
> > the syntax to be:
> >          SELECT ... [LIMIT count] [OFFSET offset]
> > LIMIT and OFFSET are independent.
>
> I like that syntax the best, but remember we are not inventing in
> a green field here.  Isn't this a feature that already exists in
> other DBMs?  We should probably copy their syntax, unless it's
> truly spectacularly awful...
>
>             regards, tom lane
>

Mysql uses LIMIT [offset,] rows
From documentation:

      LIMIT takes one or two numeric arguments. A single argument
      represents the maximum number of rows to return in a result. If two
      arguments are given the first argument is the offset to the first row to
      return, while the second is the maximum number of rows to return in the
      result.

What would be nice if somehow total number of rows could be returned.
This is often needed for altavista-like application.
Of course, I can do
select count(*) from sometable ... LIMIT offset, rows
and then
select ... from sometable ... LIMIT offset, rows
but this seems not elegant solution.

    Regards,

        Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Anyone object to simplifying INSTALL instructions?
Next
From: Oleg Bartunov
Date:
Subject: Re: [HACKERS] SELECT ... LIMIT (trial implementation)