From: Arnaud Lesauvage <thewild@freesurf.fr>
To: pgsql-performance@postgresql.org
Subject: Slow update with simple query
Date: Wed, 13 Dec 2006 11:51:10 +0100
Message-ID: <457FDB1E.6040801@freesurf.fr> (raw)
Hi list !
I am running a query to update the boolean field of a table based on
another table's fields.
The query is (changed names for readability):
UPDATE t1
SET booleanfield = (t2.field1 IN ('some', 'other') AND t2.field2 = 'Y')
FROM t2
WHERE t1.uid = t2.uid
t2.uid is the PRIMARY KEY.
t2 only has ~1000 rows, so I think it fits fully in memory.
t1 as ~2.000.000 rows.
There is an index on t1.uid also.
The explain (sorry, not explain analyze available yet) is :
Hash Join (cost=112.75..307410.10 rows=2019448 width=357)
Hash Cond: ("outer".uid= "inner".uid)
-> Seq Scan on t1 (cost=0.00..261792.01 rows=2033001 width=340)
-> Hash (cost=110.20..110.20 rows=1020 width=53)
-> Seq Scan on t2 (cost=0.00..110.20 rows=1020 width=53)
My query has been running for more than 1.5 hour now, and it is still running.
Nothing else is running on the server.
There are two multicolumn-indexes on this column (both are 3-columns indexes). One of them has a
functional column (date_trunc('month', datefield)).
Do you think the problem is with the indexes ?
The hardware is not great, but the database is on a RAID1 array, so its not bad either.
I am surprised that it takes more than 3 seconds per row to be updated.
Thanks for your opinion on this !
--
Arnaud
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: thewild@freesurf.fr
Subject: Re: Slow update with simple query
In-Reply-To: <457FDB1E.6040801@freesurf.fr>
* 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