Re: using CURSOR with PHP

From: Andrew McMillan <andrew(at)catalyst(dot)net(dot)nz>
To: mike <mike(at)partner2partner(dot)com>
Cc: Postgres-PHP <pgsql-php(at)postgresql(dot)org>
Subject: Re: using CURSOR with PHP
Date: 2002-05-18 23:59:34
Message-ID: 1021766374.30043.406.camel@kant.mcmillan.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

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?

In response to

Responses

Browse pgsql-php by date

  From Date Subject
Next Message Keary Suska 2002-05-19 01:07:28 Re: using CURSOR with PHP
Previous Message mike 2002-05-18 23:18:14 Re: using CURSOR with PHP