Re: pg_fetch_array

From: Richard Huxton <dev(at)archonet(dot)com>
To: Thanks <Thanks(at)verymuch(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: pg_fetch_array
Date: 2004-06-21 10:34:28
Message-ID: 40D6B9B4.4000209@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Thanks wrote:
> Hello....
>
> I would like to know the performance of pg_fetch_array. Cosider the code:
>
> $query = "select * from foo";
> $result = pg_query( $db, $query );
>
> while ($row = pg_fetch_array($result))
> {
> $a = $row["a"];
> $b = $row["b"];
> $c = $row["c"];
> $d = $row["d"];
> }
>
> Does php need to read database everytime when pg_fetch_array is executed in
> the while loop or all the rows have been in the memory after pg_query?

Not knowing anything in detail about the PHP drivers, I'm almost certain
that all rows are returned to PHP and then pg_fetch_array() reads that
from memory.

> If read database is needed, is there any method to copy all the rows into
> memory by using other command? (because I have a application which needs
> large amount database update/retrieval and I wish the performance of the
> overall applications run faster.)
>
> or other method you would like to recommend in order to make the faster
> response time?

Are you sure that pg_fetch_array() is the problem? Can you give an
example of what you're trying to do with the data?

PS - there's a PHP list too.
--
Richard Huxton
Archonet Ltd

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Patrick Hatcher 2004-06-21 15:24:14 Re: Slow vacuum performance
Previous Message Andrew McMillan 2004-06-21 10:11:49 Re: Slow vacuum performance