Re: using CURSOR with PHP

From: Andrew McMillan <andrew(at)catalyst(dot)net(dot)nz>
To: Keary Suska <hierophant(at)pcisys(dot)net>
Cc: Postgres-PHP <pgsql-php(at)postgresql(dot)org>
Subject: Re: using CURSOR with PHP
Date: 2002-05-18 22:24:13
Message-ID: 1021760653.30045.296.camel@kant.mcmillan.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

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?

In response to

Responses

Browse pgsql-php by date

  From Date Subject
Next Message mike 2002-05-18 23:18:14 Re: using CURSOR with PHP
Previous Message Eckhard Hoeffner 2002-05-18 19:38:18 Re: using CURSOR with PHP