pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedsetting select limit?
5+ messages / 4 participants
[nested] [flat]
* setting select limit?
@ 1999-02-11 01:36 Frank Morton <fmorton@base2inc.com>
0 siblings, 2 replies; 5+ messages in thread
From: Frank Morton @ 1999-02-11 01:36 UTC (permalink / raw)
To: pgsql-sql
If a select is going to match 1000 records, but I only want to
select the first 25, I thought I could:
select * from table limit 25;
But I guess I can't. How do I limit the query? I've search
around with no results. Thanks.
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [SQL] setting select limit?
@ 1999-02-11 02:10 Oleg Bartunov <oleg@sai.msu.su>
parent: Frank Morton <fmorton@base2inc.com>
1 sibling, 1 reply; 5+ messages in thread
From: Oleg Bartunov @ 1999-02-11 02:10 UTC (permalink / raw)
To: Frank Morton <fmorton@base2inc.com>; +Cc: pgsql-sql
You need v6.4.2-feature-patch which implement LIMIT option:
LIMIT This is a new option to the SELECT statement, telling
the database that only some of the rows selected
should be returned in the result set.
The added syntax of the LIMIT option is:
SELECT ... [LIMIT {ALL | lim} [, off]];
or
SELECT ... [LIMIT {ALL | lim}] [OFFSET off];
where lim is a positive integer value greater than
zero and off is an integer value greater or equal to
zero. Both values can be specified as Parameters when
using the server programming interface (SPI). In this
case, a zero value given in the argument for the lim
parameter means ALL.
You can find it in patches directory
Regards,
Oleg
On Wed, 10 Feb 1999, Frank Morton wrote:
> Date: Wed, 10 Feb 1999 20:36:57 -0500
> From: Frank Morton <fmorton@base2inc.com>
> To: pgsql-sql@postgreSQL.org
> Subject: [SQL] setting select limit?
>
> If a select is going to match 1000 records, but I only want to
> select the first 25, I thought I could:
>
> select * from table limit 25;
>
> But I guess I can't. How do I limit the query? I've search
> around with no results. Thanks.
>
>
>
>
_____________________________________________________________
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
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [SQL] setting select limit?
@ 1999-02-11 09:15 Jan Wieck <jwieck@debis.com>
parent: Frank Morton <fmorton@base2inc.com>
1 sibling, 0 replies; 5+ messages in thread
From: jwieck@debis.com @ 1999-02-11 09:15 UTC (permalink / raw)
To: fmorton@base2inc.com; +Cc: pgsql-sql
>
> If a select is going to match 1000 records, but I only want to
> select the first 25, I thought I could:
>
> select * from table limit 25;
>
> But I guess I can't. How do I limit the query? I've search
> around with no results. Thanks.
Exactly that syntax is provided for v6.4 in the feature patch
you find in the patches directory of the ftp server. And it
will be in the standard distribution of v6.5.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #
^ permalink raw reply [nested|flat] 5+ messages in thread
* RE: [SQL] setting select limit?
@ 1999-02-11 10:20 Neil Burrows <maillist@remo.demon.co.uk>
parent: Oleg Bartunov <oleg@sai.msu.su>
0 siblings, 1 reply; 5+ messages in thread
From: Neil Burrows @ 1999-02-11 10:20 UTC (permalink / raw)
To: Oleg Bartunov <oleg@sai.msu.su>; +Cc: pgsql-sql
Hi,
> You need v6.4.2-feature-patch which implement LIMIT option:
Or alternatively if you can't or don't want to apply a patch, have a look at
the
SET QUERY_LIMIT TO x
in Postgres 6.4
Command: set
Description: set run-time environment
Syntax:
SET DateStyle TO
'ISO'|'SQL'|'Postgres'|'European'|'US'|'NonEuropean'
set GEQO TO 'ON[=#]'|'OFF'
set R_PLANS TO 'ON'| 'OFF'
set QUERY_LIMIT TO #
function in postgres 6.4
Regards,
---[ Neil Burrows ]-----------------------------------------------------
E-mail: neil.burrows@gssec.bt.co.uk British Telecom Plc.
: neil@pawprint.co.uk Glasgow Engineering Centre
Web : http://www.remo.demon.co.uk/ Highburgh Rd. Glasgow UK
-----------< Any views expressed are not those of my employer >-----------
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: [SQL] setting select limit?
@ 1999-02-11 12:21 Jan Wieck <jwieck@debis.com>
parent: Neil Burrows <maillist@remo.demon.co.uk>
0 siblings, 0 replies; 5+ messages in thread
From: jwieck@debis.com @ 1999-02-11 12:21 UTC (permalink / raw)
To: maillist@remo.demon.co.uk; +Cc: oleg@sai.msu.su; pgsql-sql
>
> Hi,
>
> > You need v6.4.2-feature-patch which implement LIMIT option:
>
> Or alternatively if you can't or don't want to apply a patch, have a look at
> the
>
> SET QUERY_LIMIT TO x
>
> in Postgres 6.4
It is commented out by default (#ifdef QUERY_LIMIT) and I
recommend NOT to enable it.
The implementation of SET QUERY_LIMIT hat unwanted side
effects. If during the execution of such a query functions or
triggers get invoked, the query limit also affects the
execution of their queries. That could damage triggers or
give unpredictable results on functions.
I'll ensure that the SET QUERY_LIMIT code will be removed in
v6.5.
Jan
--
#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck@debis.com (Jan Wieck) #
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~1999-02-11 12:21 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-02-11 01:36 setting select limit? Frank Morton <fmorton@base2inc.com>
1999-02-11 02:10 ` Oleg Bartunov <oleg@sai.msu.su>
1999-02-11 10:20 ` Neil Burrows <maillist@remo.demon.co.uk>
1999-02-11 12:21 ` Jan Wieck <jwieck@debis.com>
1999-02-11 09:15 ` Jan Wieck <jwieck@debis.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox