Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id BBD559F946C for ; Wed, 13 Dec 2006 06:51:22 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-new, port 10024) with ESMTP id 79342-07 for ; Wed, 13 Dec 2006 06:51:11 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from serveurmail01.codata.be (125.123.146.82.ipv4.evonet.be [82.146.123.125]) by postgresql.org (Postfix) with ESMTP id CE1E89FB1D0 for ; Wed, 13 Dec 2006 06:51:14 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by serveurmail01.codata.be (Postfix) with ESMTP id 224DF1838777 for ; Wed, 13 Dec 2006 11:51:13 +0100 (CET) X-DSPAM-Result: Innocent X-DSPAM-Processed: Wed Dec 13 11:51:09 2006 X-DSPAM-Confidence: 0.5394 X-DSPAM-Probability: 0.0000 X-DSPAM-Signature: 457fdb1d271802932916029 X-DSPAM-Factors: 27, X-Virus-Scanned: amavisd-new at Received: from serveurmail01.codata.be ([127.0.0.1]) by localhost (serveurmail01.codata.be [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id sjWVhwifW4hC for ; Wed, 13 Dec 2006 11:51:09 +0100 (CET) Received: from [127.0.0.1] (38-179-112-217.fix.adsl.belcenter.be [217.112.179.38]) by serveurmail01.codata.be (Postfix) with ESMTP id C16DB1838726 for ; Wed, 13 Dec 2006 11:51:08 +0100 (CET) Message-ID: <457FDB1E.6040801@freesurf.fr> Date: Wed, 13 Dec 2006 11:51:10 +0100 From: Arnaud Lesauvage User-Agent: Thunderbird 1.5.0.8 (Windows/20061025) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Slow update with simple query Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Antivirus: avast! (VPS 0657-2, 12/12/2006), Outbound message X-Antivirus-Status: Clean X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/313 X-Sequence-Number: 22369 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