Re: PGresult pointer and memory usage

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Jeff Davis <jdavis-pgsql(at)empires(dot)org>
Cc: PgSQL General List <pgsql-general(at)postgresql(dot)org>
Subject: Re: PGresult pointer and memory usage
Date: 2005-01-24 22:08:31
Message-ID: 20050124220826.GF11438@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

From what I understand:

On Mon, Jan 24, 2005 at 12:14:09PM -0800, Jeff Davis wrote:
> When you do a PQexec call in libpq, does PostgreSQL produce the entire
> result in memory on the server side, and then does libpq hold the entire
> result in memory after it retrieves it?

The server sends the data straight and then forgets it, but the client
library stores all the results before returning.

> The only time that the server sends parts of the result at a time is
> with a cursor, right? And libpq always holds the data that it gets back,
> right?

In a sense. The result of a FETCH is the whole resultset for that
statement, but it keeps the query around for other FETCHes. I don't
believe it holds the entire result (although maybe with a sort...???)

Hope this helps,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Christopher Browne 2005-01-24 23:30:52 Re: Recursive queries
Previous Message mstory 2005-01-24 20:48:18 Re: Calculating a moving average (Coding style)