storing C binary array in bytea via libpq

From: Tom DalPozzo <t(dot)dalpozzo(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: storing C binary array in bytea via libpq
Date: 2016-12-06 18:06:16
Message-ID: CAK77FCS=v-qKAEf_AYJUo=G3FNvGnZKRTCCOnexFpKVACsTjmg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
I've a table in which a field is BYTEA, as I need to store around 200 raw
bytes in this field.
I need to perform many many INSERT starting from a common C array and, in
order to get good performance, I want to do many of them in a single BEGIN
COMMIT block.
What is the best choice from libpq?
PQexec needs to have the bytes encoded into a string. This expansion lowers
the performance (I tried with \x format, not with the other option yet).
With PQexecParams, can I send a raw array of bytes as a bytea parameter?
And also, as PQexecParams can't accept multi commands, if I enclose many
PQexecParams calls between a PQexec("BEGIN;") and PQexec("COMMIT") would
it work as I wish?
Other options?
Regards
Pupillo

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2016-12-06 18:18:50 Re: storing C binary array in bytea via libpq
Previous Message Tom Lane 2016-12-06 17:51:36 Re: Select works only when connected from login postgres