Re: Using real libpq parameters

From: "P(dot) Christeas" <p_christ(at)hol(dot)gr>
To: psycopg(at)postgresql(dot)org
Subject: Re: Using real libpq parameters
Date: 2011-02-27 10:30:45
Message-ID: 201102271230.46901.p_christ@hol.gr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On Sunday 27 February 2011, Daniele Varrazzo wrote:
> Hello,
>
> I've tried to make order in the ideas about pros and cons of using
> real query parameters in libpq. Here is my analysis and a possible
> plan.
> ...

Sorry not to have answered this thread earlier, I've had some trouble with
kmail+akonadi which kept me silent for a couple of days :S

Yes, we have /already/ done a few experiments on using binary data types with
psycopg2. A few remarks (merely what Daniele has said):
1. When used properly, binary datatypes have significant speed gain over text
ones. But not in all cases.
2. Not all datatypes can go binary. That's not a problem in the send
direction, because we can control that with a boolean flag.
3. There is NO universally backwards compatible way of switching from text
params to binary ones. If we ever support binary, it will need an explicit
attribute/method, like the ISQLParam adaptation that Daniele has proposed.
Since breaking compatibility of psycopg2 is out of the question, so is moving
to binary mode by default.
4. In the receive direction, things are even more complex. It wouldn't be
recommended except for cases of extreme data transfers (always with the option
to fall back to the old text code).
5. libpqtypes doesn't seem to help as you suggested. It does text->net-bin
adaptations, which we don't need, since Python internal representation is
already binary. We want a bin->net-bin library (where net-bin is the network
Postgres-native format of data, heavily dependent on server's version)..
OTOH, reading the code of libpqtypes /could/ help us write ourselves similar
adapters.

Code at:
http://git.hellug.gr/?p=xrg/psycopg2;a=shortlog;h=refs/heads/execparams

--
Say NO to spam and viruses. Stop using Microsoft Windows!

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Daniele Varrazzo 2011-02-27 10:49:46 Re: Using real libpq parameters
Previous Message A.M. 2011-02-26 23:47:22 Re: Using real libpq parameters