Re: C++, Postgres , libpqxx huge query

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: alexandros_e <alexandros(dot)ef(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: C++, Postgres , libpqxx huge query
Date: 2014-05-04 09:59:06
Message-ID: AA91B77E-DF30-4892-8BF1-E6251E6370AF@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04 May 2014, at 10:57, alexandros_e <alexandros(dot)ef(at)gmail(dot)com> wrote:

> Hello experts. I have posted this question on stack overflow, but I did not
> get any detailed answer, so I thought I should cross post here. My
> apologies.
>
> 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.
>
> try {
> work W(*Conn);
> result r = W.exec(sql[sqlLoad]);
> W.commit();
>
> for (int rownum = 0; rownum < r.size(); ++rownum) {
> const result::tuple row = r[rownum];
> vid1 = row[0].as<int>();
> vid2 = row[1].as<int>();
> vid3 = row[2].as<int>();
> .....
>
> } catch (const std::exception &e) {
> std::cerr << e.what() << std::endl;
> }
>
> I am using PostgreSQL 9.3 and there I see this
> http://www.postgresql.org/docs/9.3/static/libpq-single-row-mode.html, but I
> do not how to use it on my C++ code. Your help will be appreciated.

I think the section of relevance is: http://www.postgresql.org/docs/9.3/static/libpq-async.html

Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andres Freund 2014-05-04 10:24:47 Re: C++, Postgres , libpqxx huge query
Previous Message Alexandros Efentakis 2014-05-04 09:48:50 Re: C++, Postgres , libpqxx huge query