![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
=20 |
;<br></blockquote></div><=
#3
| |||
| |||
|
|
Symptom: even the simplest query $result = pg_query($db, "SELECT * FROM big_table"); eats enormous amounts of memory on server (proportional to table size). |
#4
| |||
| |||
|
|
The same php script but done against Oracle does not have this behaviour. |
#5
| |||
| |||
|
|
Denis, $result = pg_query($db, "SELECT * FROM big_table"); you are reading a big result (as I suspect from big_table) into memory. It is perfectly normal that this uses large amounts of memory. |
|
[it would be rather suspicious if loading a big file / big resultset would not use big amounts of memory] -- |
#6
| |||
| |||
|
|
Denis Vlasenko wrote: Symptom: even the simplest query $result = pg_query($db, "SELECT * FROM big_table"); eats enormous amounts of memory on server (proportional to table size). Right, which is exactly what you would expect. The entire result set is sent to the client and stored in local memory; if you only want to process part of the result set at a time, use a cursor. |
|
(And I'm a little suspicious that the performance of "SELECT * FROM big_table" will contribute to a meaningful comparison between database systems.) |
#7
| |||
| |||
|
|
I wanted to show colleagues which are Oracle admins that peak data fetch rate of PostgreSQL is way better than Oracle one. While it turned out to be true (Oracle+WinNT = 2kb TCP output buffer, ~1Mb/s over 100Mbit; PostgreSQL+Linux = 8kb buffer, ~2.6Mb/s), I was ridiculed instead when my php script failed miserably, crashing Apache with OOM condition, while alanogous script for Oracle ran to completion just fine. |
#8
| |||
| |||
|
|
Denis Vlasenko wrote: The same php script but done against Oracle does not have this behaviour. Perhaps; presumably Oracle is essentially creating a cursor for you behind the scenes. libpq does not attempt to do this automatically; if you need a cursor, you can create one by hand. |
#9
| |||
| |||
|
|
Neil Conway wrote: Denis Vlasenko wrote: The same php script but done against Oracle does not have this behaviour. Perhaps; presumably Oracle is essentially creating a cursor for you behind the scenes. libpq does not attempt to do this automatically; if you need a cursor, you can create one by hand. I do not understand how a cursor could be autocreated by a query like $result = pg_query($db, "SELECT * FROM big_table"); php will expect $result to contain the entire table (yuck!). |
#10
| |||
| |||
|
|
Bug reference: 1756 Logged by: Denis Vlasenko Email address: vda (AT) ilport (DOT) com.ua PostgreSQL version: 8.0.1 Operating system: Linux Description: PQexec eats huge amounts of memory |
![]() |
| Thread Tools | |
| Display Modes | |
| |