Re: contrib: hack for psycopg2 performance
Karsten Hilbert <[email protected]> Wed, 12 May 2010 12:53:23 +0200
| Newsgroups | gmane.comp.python.db.psycopg.devel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, May 11, 2010 at 12:24:26AM +0100, Daniele Varrazzo wrote: > By the way I actually quite like how in PQexecParams it is possible to > specify for every param whether it is binary or not: this would > actually allow sending binary for basic data types, and falling back > to the textual representation for the less used one, allowing a > progressive and incremental transition. On the other hand the > performance increment comes at the cost of knowing the binary > representation of the different data types (it actually seems more an > interface leak than a feature...) and there is room for *a lot* of bug > in this area! > > So I think potentially there are some improvements that can be done, > but you will have to fight against the fact that psycopg is a very > generic library (I think PQexec was chosen in first instance exactly > for being more generic than the *Param equivalent) and trying to > replicate the effect of a generic function by composition of less > generic ones is not an easy task. If I remember correctly the *Params library call was invented to *get rid* of the SQL injection problem (because query assembly doesn't happen before it has arrived *inside* the server). The non-*Params variant only makes it hard to avoid injection if using the libpq based quoting (which AFAIR psycopg2 does). But maybe I'm wrong here. Karsten -- GPG key ID E4071346 @ wwwkeys.pgp.net E167 67FD A291 2BEA 73BD 4537 78B9 A9F9 E407 1346