Re: contrib: hack for psycopg2 performance

Jan UrbaƄski <[email protected]> Wed, 12 May 2010 20:20:15 +0200
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
On 12/05/10 19:04, Michael Tharp wrote:
> On 05/10/2010 05:54 PM, Daniele Varrazzo wrote:
>> PQexecParams has the shortcoming of being able to send only a query at
>> time, whereas PQexec allows to send any number in a single string,
>> separated by semicolons. Many people use this feature and dropping it
>> would be an incompatible change. How would you work around that?
> 
> Can you "pipeline" statements in libpq? e.g. send three statements as
> separate commands but without waiting for the replies to the first two.

No. The replies for the first two always come.

> Obviously any completely transparent replacement, regardless of
> implementation, would need to be able to parse enough SQL to reliably
> split statements. I don't suppose that would be terribly difficult
> because SQL quoting rules are fairly simple, but it's still more work to
> be done.

I think that'd be a fairly bad idea. The less query munging psycopg2
does, the better IMHO. To do reliable splitting is would have to
understand dollar-quoting, escape string syntax etc.

> Also this will break everyone's custom typecasters, which will need some
> way to do whatever formatting is required for parameterized values. That
> said, I'm kind of interested in seeing where this goes.

Yeah, good point.

Cheers,
Jan