Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 31F0C64FCE3 for ; Sun, 16 Nov 2008 10:56:54 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 15957-08 for ; Sun, 16 Nov 2008 10:56:51 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from 27.mail-out.ovh.net (27.mail-out.ovh.net [91.121.30.210]) by mail.postgresql.org (Postfix) with SMTP id 84DB464FCAC for ; Sun, 16 Nov 2008 10:56:51 -0400 (AST) Received: (qmail 6376 invoked by uid 503); 16 Nov 2008 16:04:43 -0000 Received: from gw2.ovh.net (HELO mail54.ha.ovh.net) (213.251.189.202) by 27.mail-out.ovh.net with SMTP; 16 Nov 2008 16:04:43 -0000 Received: from b0.ovh.net (HELO queue-out) (213.186.33.50) by b0.ovh.net with SMTP; 16 Nov 2008 14:49:45 -0000 Received: from par69-8-88-161-102-87.fbx.proxad.net (HELO soyouz) (88.161.102.87) by ns0.ovh.net with SMTP; 16 Nov 2008 14:49:40 -0000 Date: Sun, 16 Nov 2008 15:50:28 +0100 To: firerox@centrum.cz, "pgsql-performance@postgresql.org" Subject: Re: slow full table update From: PFC Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 References: <200811101728.3048@centrum.cz> <200811101729.14977@centrum.cz> <200811101730.15902@centrum.cz> <200811122347.21602@centrum.cz> Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: <200811122347.21602@centrum.cz> User-Agent: Opera Mail/9.62 (Linux) X-Ovh-Tracer-Id: 3676063196195653225 X-Ovh-Remote: 88.161.102.87 (par69-8-88-161-102-87.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|H 0.5/N X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200811/141 X-Sequence-Number: 31872 > update songs set views = 0; > UPDATE 54909 > Time: 101907.837 ms > time is actually less than 10 minutes, but it is still very long :( Wow. test=> CREATE TABLE test (id SERIAL PRIMARY KEY, value INTEGER); test=> INSERT INTO test (value) SELECT n FROM generate_series( 1,100000 ) AS n; Temps : 1706,495 ms test=> UPDATE test SET value=0; Temps : 1972,420 ms Note this is 8.3.3 on a desktop PC with the database and xlog on a Linux Software RAID1 of rather slow drives (about 50 MB/s). Anyway your 10 minutes are really wrong. First thing to check is if there is a problem with your IO subsystem, try the example queries above, you should get timings in the same ballpark. If you get 10x slower than that, you have a problem. Are the rows large ? I would believe so, because a "songs" table will probably contain things like artist, title, comments, and lots of other information in strings that are too small to be TOAST'ed. Perhaps your problem is in index updates, too. So, make a copy of the songs table, without any indices, and no foreign keys : CREATE TABLE songs2 AS SELECT * FROM songs; Then try your UPDATE on this. How slow is it ? Now drop this table, and recreate it with the foreign keys. Test the update again. Now drop this table, and recreate it with the foreign keys and indexes. Test the update again. This will give you some meaningful information. You will probably update the 'views' column quite often, it will even probably be the most often updated column in your application. In this case, you could try moving it to a separate table with just (song_id, view), that way you will update a very small table.