Re: [HACKERS] SELECT ... LIMIT (trial implementation)

From: Oleg Bartunov <oleg(at)sai(dot)msu(dot)su>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>, pgsql-hackers(at)postgreSQL(dot)org, jwieck(at)debis(dot)com
Subject: Re: [HACKERS] SELECT ... LIMIT (trial implementation)
Date: 1998-10-18 17:45:24
Message-ID: Pine.GSO.3.96.SK.981018213213.17519C-100000@ra
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, 18 Oct 1998, Tom Lane wrote:

> Date: Sun, 18 Oct 1998 12:04:49 -0400
> From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
> To: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
> Cc: pgsql-hackers(at)postgreSQL(dot)org
> Subject: Re: [HACKERS] SELECT ... LIMIT (trial implementation)
>
> Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)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(at)sai(dot)msu(dot)su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Oleg Bartunov 1998-10-18 17:58:41 Re: [HACKERS] SELECT ... LIMIT (trial implementation)
Previous Message Tom Lane 1998-10-18 17:35:29 Anyone object to simplifying INSTALL instructions?