Re: Problems with an update-from statement and pg-8.1.4

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Rafael Martinez <r(dot)m(dot)guerrero(at)usit(dot)uio(dot)no>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Problems with an update-from statement and pg-8.1.4
Date: 2006-12-06 19:20:44
Message-ID: 20061206111630.R8187@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Wed, 6 Dec 2006, Rafael Martinez wrote:

> We are having some problems with an UPDATE ... FROM sql-statement and
> pg-8.1.4. It takes ages to finish. The problem is the Seq Scan of the
> table 'mail', this table is over 6GB without indexes, and when we send
> thousands of this type of statement, the server has a very high iowait
> percent.
>
> How can we get rid of this Seq Scan?
>
> I send the output of an explain and table definitions:
> -------------------------------------------------------------------------
>
> mailstats=# EXPLAIN update mail SET spamscore = '-5.026' FROM mail m,
> mail_received mr where mr.mail_id = m.mail_id AND mr.queue_id =
> '1GrxLs-0004N9-I1' and mr.mailhost = '129.240.10.47';

I don't think this statement does what you expect. You're ending up with
two copies of mail in the above one as "mail" and one as "m". You probably
want to remove the mail m in FROM and use mail rather than m in the
where clause.

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Ted Allen 2006-12-06 19:55:14 Re: Problems with an update-from statement and pg-8.1.4
Previous Message Rafael Martinez 2006-12-06 19:10:43 Problems with an update-from statement and pg-8.1.4