X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id ED79A11F611E for ; Fri, 7 Apr 2006 11:00:57 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35133-06 for ; Fri, 7 Apr 2006 11:00:50 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from pat.uio.no (pat.uio.no [129.240.10.6]) by postgresql.org (Postfix) with ESMTP id 8C9A811F6026 for ; Fri, 7 Apr 2006 11:00:54 -0300 (ADT) Received: from mail-mx2.uio.no ([129.240.10.30]) by pat.uio.no with esmtp (Exim 4.43) id 1FRrW9-0002Yy-JV; Fri, 07 Apr 2006 16:00:53 +0200 Received: from bbking.uio.no ([129.240.201.179]) by mail-mx2.uio.no with esmtps (TLSv1:AES256-SHA:256) (Exim 4.43) id 1FRrW1-0006Fj-9o; Fri, 07 Apr 2006 16:00:45 +0200 Subject: Re: Same SQL, 104296ms of difference between 7.4.12 and From: Rafael Martinez Guerrero To: Richard Huxton Cc: pgsql-performance@postgresql.org In-Reply-To: <443669A5.2000603@archonet.com> References: <1144413933.24060.253.camel@bbking.uio.no> <443669A5.2000603@archonet.com> Content-Type: text/plain Organization: University of Oslo Message-Id: <1144418444.24060.269.camel@bbking.uio.no> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.5 (1.4.5-17) Date: Fri, 07 Apr 2006 16:00:44 +0200 Content-Transfer-Encoding: 7bit X-UiO-Spam-info: not spam, SpamAssassin (score=-5.377, required 12, autolearn=disabled, AWL -0.38, UIO_MAIL_IS_INTERNAL -5.00) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200604/128 X-Sequence-Number: 18212 On Fri, 2006-04-07 at 15:31, Richard Huxton wrote: > Rafael Martinez Guerrero wrote: > > Hello > > > > I have a sql statement that takes 108489.780 ms with 8.0.7 in a > > RHEL4/amd64linux server with 2xAMD Opteron(tm) Processor 275 2.00GHz / > > 8GB RAM and only 4193.588 ms with 7.4.12 in a RHEL3/386linux server with > > 2xIntel(R) Xeon(TM) CPU 2.40GHz / 4GB RAM. > > > > Some information: > > > > - There is no IO when I am running the sql, but it uses 99% of the cpu. > > - I run VACUUM VERBOSE ANALYZE in both databases before the test. > > - The databases are identical. > > - No other jobs running when testing. > > - Some different parameters between 7.4.12 and 8.0.7 : > > > > 7.4.12: > > ------- > > shared_buffers = 114966 #(15% of ram) > > sort_mem = 16384 > > vacuum_mem = 524288 > > wal_buffers = 64 > > checkpoint_segments = 16 > > effective_cache_size = 383220 #(50% ram) > > random_page_cost = 3 > > default_statistics_target = 100 > > > > 8.0.7: > > ------ > > shared_buffers = 250160 #(25% ram) > > work_mem = 8192 > > maintenance_work_mem = 131072 > > wal_buffers = 128 > > checkpoint_segments = 64 > > effective_cache_size = 500321 #(50% ram) > > random_page_cost = 3 > > default_statistics_target = 100 > > > > Any ideas of what I can test/configurate to find out why this happens? > > Thanks in advance. > > I haven't looked in detail at the plans, but what stands out to me is > that you've got a sort with a lot of columns and you've halved sort_mem > (work_mem). Try increasing it (perhaps to 32000 even). > set work_mem = 32000; > > Give that a quick go and see what happens. If it doesn't work, we'll > look at the plans in more detail. I know that this SQL could be done in a much better way, but I can not change it at the moment. work_mem = 16384: ----------------- After restarting the database and running the explain two times: 107911.229 ms work_mem = 32768: ----------------- After restarting the database and running the explain two times: 103988.337 ms -- Rafael Martinez, Center for Information Technology Services University of Oslo, Norway PGP Public Key: http://folk.uio.no/rafael/