Re: BUG #18775: PQgetCopyData always has an out-of-memory error if the table field stores bytea ~700 MB - Mailing list pgsql-bugs

From Ilya Knyazev
Subject Re: BUG #18775: PQgetCopyData always has an out-of-memory error if the table field stores bytea ~700 MB
Date
Msg-id CAFqQ4ZWyUwwwgHA+BBGiLKbmm+SaRPJZQSgOHajDa+AB+igfRA@mail.gmail.com
Whole thread Raw
In response to Re: BUG #18775: PQgetCopyData always has an out-of-memory error if the table field stores bytea ~700 MB  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: BUG #18775: PQgetCopyData always has an out-of-memory error if the table field stores bytea ~700 MB
List pgsql-bugs
Thanks for the answer. I agree that if you want to work with large data, then make sure you have enough memory. If you call the PQexec function with a regular select and then PQgetvalue to get the value. And you get an error - then it's your own fault.
But I know that there may not be enough memory, so I use the "copy" keyword in the query and the PQgetCopyData function. I thought that this function was designed for portioned work. By analogy with the PQputCopyData function, which works fine.

I found a way out. I use "SELECT substring(%s from %d for %d) as chunk from %s.%s WHERE %s = %s" with PQunescapeBytea in a loop. But it looks strange and takes longer.

p .s
I specified that my file is 300+ MB, not 700+.

чт, 16 янв. 2025 г. в 19:03, Tom Lane <tgl@sss.pgh.pa.us>:
PG Bug reporting form <noreply@postgresql.org> writes:
> Hello, I need your help. The essence of the problem is that I am trying to
> download a bytea field from a table row. The size of the data in the field
> is about 700 MB. In response, I receive an out-of-memory error.

I don't see this as a Postgres bug.  If you want to work with values
that large, you'd better have plenty of memory available.

                        regards, tom lane


--
С уважением,
Князев И. Н.       
  

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #18775: PQgetCopyData always has an out-of-memory error if the table field stores bytea ~700 MB
Next
From: PG Bug reporting form
Date:
Subject: BUG #18777: Error running unnest function in a two phase commit transaction