Re: cursor interface to libpq

Поиск
Список
Период
Сортировка
От Thomas Lockhart
Тема Re: cursor interface to libpq
Дата
Msg-id 39C84F0A.9E6C5947@alumni.caltech.edu
обсуждение исходный текст
Ответ на cursor interface to libpq  ("Kirby Bohling (TRSi)" <kbohling@oasis.novia.net>)
Ответы Re: cursor interface to libpq  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: cursor interface to libpq  ("Kirby Bohling (TRSi)" <kbohling@oasis.novia.net>)
Список pgsql-interfaces
> I am trying to run a select statement, and I keep running out of
> memory.  I have noticed that libpq has the nice feature that I don't have
> to request each row one at a time.  After a little investigate, I found
> that libpq appears to get the entire result set at once.  Well, at least
> PQgetvalue() doesn't appear to do anything besides return a pointer to a
> string.  There is no lazy evaluation.  It doesn't just fetch the row I
> need, and flush old ones as memory permits.

Use a cursor at the query level to keep the result set in the backend.
But you will still (possibly) run out of memory, since the *backend*
must keep the result set in memory and/or on disk. Make sure you have
enough swap space, disk space, and main memory to handle the size of
database you have.

>         Is there any interface that I can link to a C/C++ program that
> will allow me row at a time access to the data?  Not being able to run
> select statements is going to be a fairly sizeable problem for me.

Look at cursors, but that doesn't eliminate the need for enough memory.

Expect to buy more memory, and make sure you have enough swap space.
Send more details on what you have currently and what your database
looks like and we can give you better feedback on your resource
requirements.
                     - Thomas


В списке pgsql-interfaces по дате отправления:

Предыдущее
От: Tom Samplonius
Дата:
Сообщение: Re: PHP & Large Object
Следующее
От: Tom Lane
Дата:
Сообщение: Re: cursor interface to libpq