Skip site navigation (1) Skip section navigation (2)

Re: BUG #1756: PQexec eats huge amounts of memory

From: Denis Vlasenko <vda(at)ilport(dot)com(dot)ua>
To: Harald Armin Massa <haraldarminmassa(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1756: PQexec eats huge amounts of memory
Date: 2005-07-07 05:21:38
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
On Wednesday 06 July 2005 16:52, Harald Armin Massa wrote:
> 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.

No, I am not reading it into memory. I am executing query _on the server_,
fetching result row-by-row and discarding rows as prey are processed
(i.e. without accumulating all rows in _client's memory_) in the part
of php script which you snipped off.

Similar construct with Oracle, with 10x larger table,
does not use Apache (php) memory significantly.
php's pg_query() calls PQuery(), a Postgresql client library function,
which is likely implemented so that it fetches all rows and stores them
in client's RAM before completion.

Oracle OCI8 does not work this way, it keeps result set
on db server (in a form of a cursor or something like that).

> [it would be rather suspicious if loading a big file / big resultset would 
> not use big amounts of memory]

In response to

pgsql-bugs by date

Next:From: Neil ConwayDate: 2005-07-07 05:54:29
Subject: Re: BUG #1756: PQexec eats huge amounts of memory
Previous:From: Steve BennettDate: 2005-07-06 21:31:40
Subject: BUG #1757: timestamp 'epoch' is not absolute

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group