pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew McMillan <andrew@catalyst.net.nz>
To: mike <mike@partner2partner.com>
Cc: Postgres-PHP <pgsql-php@postgresql.org>
Subject: Re: using CURSOR with PHP
Date: 19 May 2002 11:59:34 +1200
Message-ID: <1021766374.30043.406.camel@kant.mcmillan.net.nz> (raw)
In-Reply-To: <20020518231814.22057.qmail@conan.partner2partner.org>
References: <B90BFA62.E93F%hierophant@pcisys.net>
	<1021760653.30045.296.camel@kant.mcmillan.net.nz>
	<20020518231814.22057.qmail@conan.partner2partner.org>

On Sun, 2002-05-19 at 11:18, mike wrote:
> Andrew McMillan writes:
> > PostgreSQL will certainly take LIMIT into account when planning queries.
> 
> I would think most queries using LIMIT would also include an ORDER BY clause 
> which would require PostgreSQL to sort all the results before applying the 
> LIMIT. 

Then you would be wrong.  ORDER BY can also be handled by an index, if
there is an appropriate one, and this is where PostgreSQL will switch
query plans because traversing an index to grab a few hundred records is
much faster than a sequential scan and sort of many thousands.

With 7.2 PostgreSQL is getting pretty smart with its query planning, but
recognising limits and doing index scans is something that has been
around since at least 7.0, possibly earlier.


> > OTOH PostgreSQL does _not_ do result caching, unless you have applied
> > some patches that were floating around last year some time.
> 
> PostgreSQL might not do 'result caching' but if you have an adequate number 
> of buffers configured would it not be likely that the results from the last 
> query are still in memory? 

Yep.  Or the tables could be in Linux' file cache too, but neither of
those provides the same huge performance boost that result caching will
in those few narrow situations in which it applies.

I'd really like to see result caching incorporated into PostgreSQL at
some point but there are many features like that.  Being able to
natively create full-text indexes remains my most wished-for feature.

Cheers,
					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?




view thread (23+ messages)  latest in thread

Message-ID: <1021766374.30043.406.camel@kant.mcmillan.net.nz>
Permalink:  ../1021766374.30043.406.camel@kant.mcmillan.net.nz/
Also on:    postgresql.org/message-id/1021766374.30043.406.camel@kant.mcmillan.net.nz

 · 

reply

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, mike@partner2partner.com
  Subject: Re: using CURSOR with PHP
  In-Reply-To: <1021766374.30043.406.camel@kant.mcmillan.net.nz>
  References: <B90BFA62.E93F%hierophant@pcisys.net> <1021760653.30045.296.camel@kant.mcmillan.net.nz> <20020518231814.22057.qmail@conan.partner2partner.org> <1021766374.30043.406.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