pg_fetch_array

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?

If read database is needed, is there any method to copy all the things 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?

Thank you in advance.





---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend
Thanks [ Mo, 14 Juni 2004 07:02 ] [ ID #141872 ]

Re: pg_fetch_array

Thanks [at] verymuch.com wrote:

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

The latter - pg_query puts all of the rows in memory. I found this out myself recently. Select a
lot of rows using pg_query without pg_fetch_array. As you're doing this, watch he memory usage
with 'free -s 1'.

George Essig

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo [at] postgresql.org)
George Essig [ Mo, 21 Juni 2004 23:09 ] [ ID #141873 ]
Datenbanken » gmane.comp.db.postgresql.php » pg_fetch_array

Vorheriges Thema: PostgreSQL guru needed for Enterprise Groupware System
Nächstes Thema: PHP Installation