Re: UPDATE runs slow in a transaction

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Viktor Rosenfeld <rosenfel(at)informatik(dot)hu-berlin(dot)de>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: UPDATE runs slow in a transaction
Date: 2008-07-14 18:52:27
Message-ID: 29834.1216061547@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Viktor Rosenfeld <rosenfel(at)informatik(dot)hu-berlin(dot)de> writes:
> the script below runs very fast when executed alone. But when I call
> it from within a transaction block it's so slow that I have to abort
> it after a while. Specifically the second-to-last UPDATE seems to
> take forever within a transaction while it completes in about 3
> seconds outside a transaction.

Since the table you're working on was just created in the same
transaction, there's been no opportunity for autovacuum to run an
ANALYZE on it; that's probably preventing selection of a good plan.
Try throwing in an "ANALYZE tmp" after you load the table.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-07-14 19:02:04 Re: statement timeout and pg_dump
Previous Message Tom Lane 2008-07-14 18:20:14 Re: How to remove the possibility to search the parts of a compound word with hyphen