From: Andrew McMillan <andrew@catalyst.net.nz>
To: Keary Suska <hierophant@pcisys.net>
Cc: Postgres-PHP <pgsql-php@postgresql.org>
Subject: Re: using CURSOR with PHP
Date: 19 May 2002 10:24:13 +1200
Message-ID: <1021760653.30045.296.camel@kant.mcmillan.net.nz> (raw)
In-Reply-To: <B90BFA62.E93F%hierophant@pcisys.net>
References: <B90BFA62.E93F%hierophant@pcisys.net>
On Sun, 2002-05-19 at 06:32, Keary Suska wrote:
>
> The drawback to using LIMIT is that you are executing the query on every
> call, and Postgres cannot optimize on a LIMIT as was mentioned, because the
> entire query has to be collected before the LIMIT can be applied. However,
> IIRC, Postgres does query result caching, so subsequent calls on the same
> query will tend to be faster, providing there is enough memory allocated to
> support it.
PostgreSQL will certainly take LIMIT into account when planning queries.
EXPLAIN SELECT * FROM mybigtable WHERE x = y;
and
EXPLAIN SELECT * FROM mybigtable WHERE x = y LIMIT n;
Will regularly show different query plans.
For more complex queries, however, the plans are less likely to differ
by much.
OTOH PostgreSQL does _not_ do result caching, unless you have applied
some patches that were floating around last year some time.
Regards,
Andrew.
--
--------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267
Are you enrolled at http://schoolreunions.co.nz/ yet?
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: andrew@catalyst.net.nz, hierophant@pcisys.net
Subject: Re: using CURSOR with PHP
In-Reply-To: <1021760653.30045.296.camel@kant.mcmillan.net.nz>
References: <B90BFA62.E93F%hierophant@pcisys.net> <1021760653.30045.296.camel@kant.mcmillan.net.nz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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