Re: C++, Postgres , libpqxx huge query - Mailing list pgsql-general

From Alexandros Efentakis
Subject Re: C++, Postgres , libpqxx huge query
Date
Msg-id CAALHc0WpMwHt9_9+xF+D6P9Qokk2QOBWgYm1giX019MaH=-FNQ@mail.gmail.com
Whole thread Raw
In response to C++, Postgres , libpqxx huge query  (alexandros_e <alexandros.ef@gmail.com>)
List pgsql-general
Thanks John for your answer. The problem is how do I declare the cursor and fetch through C++ and libpq++? And if I fetch 1000 rows at a time, then how do I handle that when I reach the end and there are less than 1000 rows available? Or I need to fetch one row at a time like this http://stackoverflow.com/questions/16128142/how-to-use-pqxxstateless-cursor-class-from-libpqxx?

A.


2014-05-04 12:11 GMT+03:00 John R Pierce <pierce@hogranch.com>:
On 5/4/2014 1:57 AM, alexandros_e wrote:
I have to execute an SQL query to Postgres by the following code. The query
returns a huge number of rows (40M or more) and has 4 integer fields: When I
use a workstation with 32Gb everything works but on a 16Gb workstation the
query is very slow (due to swapping I guess). Is there any way to tell the
C++ to load rows at batches, without waiting the entire dataset? With Java I
never had these issues before, due to the probably better JDBC driver.

see DECLARE and FETCH.

http://www.postgresql.org/docs/current/static/sql-declare.html
http://www.postgresql.org/docs/current/static/sql-fetch.html





--
john r pierce                                      37N 122W
somewhere on the middle of the left coast


pgsql-general by date:

Previous
From: Tim Clarke
Date:
Subject: Re: envelope/postage announcement
Next
From: Alexandros Efentakis
Date:
Subject: Re: C++, Postgres , libpqxx huge query