Re: Memory exhaustion on large query

From: Brice André <brice(at)famille-andre(dot)be>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Memory exhaustion on large query
Date: 2021-12-14 03:31:19
Message-ID: CAOBG12nRQEb_-NfEsUHXQ_XV2mhvEb+9iKzdu-fP=XDway3B1Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Many thanks for your help.

A call to PQsetSingleRowMode just after PQsendQueryPrepared solved my issue.

Regards,
Brice

Le dim. 12 déc. 2021 à 19:43, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> a écrit :

> =?UTF-8?B?QnJpY2UgQW5kcsOp?= <brice(at)famille-andre(dot)be> writes:
> > The content of the table is so huge that, if PQsendQueryPrepared
> retrieves
> > all data, or if postgresql engine is creating temp file with all data,
> the
> > query cannot succeed (I have no enough RAM or disk space to copy the
> whole
> > data). But I was expecting that using PQsendQueryPrepared and PQgetResult
> > would avoid this by returning one result at a time.
>
> You're confusing asynchronous mode with single-row mode. Async mode,
> per se, doesn't change memory consumption; it just lets you do something
> else while waiting for the query result. You are (I suppose) missing
> a call to PQsetSingleRowMode --- see
>
> https://www.postgresql.org/docs/current/libpq-single-row-mode.html
>
> regards, tom lane
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Rob Sargent 2021-12-14 03:47:16 Re: 5 tables with 3 different relation cases
Previous Message JORGE MALDONADO 2021-12-14 02:32:22 5 tables with 3 different relation cases