From: Kenneth Marshall <ktm@rice.edu>
To: Dmitriy Igrishin <dmitigr@gmail.com>
Cc: Steve <steeeeeveee@gmx.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: Question about PQexecParams
Date: Thu, 30 Sep 2010 14:14:08 -0500
Message-ID: <20100930191408.GJ14003@aart.is.rice.edu> (raw)
In-Reply-To: <AANLkTim1o+u+THqciimefreDf-oRfjBGkg2SX36rHedS@mail.gmail.com>
References: <20100911124423.75020@gmx.net>
<AANLkTikZjB5M=CMVt-bNEnWS+bVN0MSdod_KZKKAZmnJ@mail.gmail.com>
<20100922100715.123530@gmx.net>
<20100930171253.GI14003@aart.is.rice.edu>
<AANLkTim1o+u+THqciimefreDf-oRfjBGkg2SX36rHedS@mail.gmail.com>
On Thu, Sep 30, 2010 at 10:30:16PM +0400, Dmitriy Igrishin wrote:
> Hey Kenneth,
>
> Thank you for solution. But sorry, personally, I don't clearly
> understand the benefits of this code compared with using
> simple array literals or even array constructors...
> Conversion "overheads" from text? Doubtfully...
>
> --
> // Dmitriy.
There are three benefits:
- reduces the CPU overhead in both the client and the DB server
for converting to/from ASCII numbers
- decreases the amount of network traffic by more than 1/2
- binary transmission of query parameters helps protect against
SQL injection attacks
Obviously, this is not as important for low performance systems,
with the possible exception of preventing SQL injection attacks,
but on high performance systems, minimizing the CPU overhead
due to data conversions is very useful indeed.
Whether or not someone chooses to use it would need to be
evaluated on a case-by-case basis. I posted the code because
the details on how to use binary array transmission needed
close examination of the documentation as well as the database
sources. If you are using PostgreSQL 8.3 or higher, and can
use an add on library, libpqtypes provides a very nice and
very useful API for managing binary parameter transmission.
I really hope that it could be included in the core PostgreSQL
to help others avoid the need to troll through the grotty
inner-workings of the database to figure out how to do this
using just libpq.
Cheers,
Ken
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ktm@rice.edu, dmitigr@gmail.com, steeeeeveee@gmx.net
Subject: Re: Question about PQexecParams
In-Reply-To: <20100930191408.GJ14003@aart.is.rice.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox