Re: Slow UPADTE, compared to INSERT

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Ivar Zarans <iff(at)alcaron(dot)ee>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Slow UPADTE, compared to INSERT
Date: 2003-12-05 17:28:30
Message-ID: 87ad672myp.fsf@stark.dyndns.tv
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Ivar Zarans <iff(at)alcaron(dot)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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message William Yu 2003-12-05 19:06:25 Slightly OT -- Xeon versus Opteron Comparison
Previous Message Josh Berkus 2003-12-05 17:26:05 Re: tuning questions