From: Greg Stark <gsstark@mit.edu>
To: Ivar Zarans <iff@alcaron.ee>
Cc: pgsql-performance@postgresql.org
Subject: Re: Slow UPADTE, compared to INSERT
Date: 05 Dec 2003 12:28:30 -0500
Message-ID: <87ad672myp.fsf@stark.dyndns.tv> (raw)
In-Reply-To: <20031205131325.GB27524@alcaron.ee>
References: <20031204185751.GA15893@alcaron.ee>
<20031205014514.GA21079@alcaron.ee>
<20031205020728.GA21440@alcaron.ee>
<200312051008.20317.dev@archonet.com>
<20031205123843.GA27170@alcaron.ee>
<3FD07EEA.8030007@persistent.co.in>
<20031205131325.GB27524@alcaron.ee>
Ivar Zarans <iff@alcaron.ee> writes:
> > qry = "UPDATE table1 SET status = %s WHERE recid = '%s'"
> > cursor.execute(qry, status, recid)
>
> Yes, this helps. But then it sort of obsoletes PyPgSQL-s own quoting
> logic. I would prefer to take care of this all by myself or trust some
> underlying code to do this for me. And PyPgSQL is quite nice - it
> checks datatype and acts accordingly.
You should tell the PyPgSQL folk to use the new binary protocol for parameters
so that there are no quoting issues at all.
But if it's going to interpolate strings into the query then pyPgSQL really
ought to be doing '%s' as above even for numbers. This lets postgres decide
what the optimal datatype is based on what you're comparing it to. Skipping
the quotes will only cause headaches.
--
greg
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-performance@postgresql.org
Cc: gsstark@mit.edu, iff@alcaron.ee
Subject: Re: Slow UPADTE, compared to INSERT
In-Reply-To: <87ad672myp.fsf@stark.dyndns.tv>
* 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