X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CB032D7207 for ; Fri, 21 Oct 2005 09:34:24 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 83355-01 for ; Fri, 21 Oct 2005 12:34:20 +0000 (GMT) Received: from pjetlic.mobart.hr (pjetlic.mobart.hr [80.80.51.10]) by svr1.postgresql.org (Postfix) with ESMTP id 83CC2D9E0A for ; Fri, 21 Oct 2005 09:34:22 -0300 (ADT) Received: from localhost (localhost.localdomain [127.0.0.1]) by pjetlic.mobart.hr (Postfix) with ESMTP id 5231817A4D; Fri, 21 Oct 2005 14:34:26 +0200 (CEST) Received: from pjetlic.mobart.hr ([127.0.0.1]) by localhost (pjetlic [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 27506-01; Fri, 21 Oct 2005 14:34:26 +0200 (CEST) Received: from mike.mobart.hr (mike.mobart.hr [192.168.10.94]) (using SSLv3 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by pjetlic.mobart.hr (Postfix) with ESMTP id 1E7E317A4B; Fri, 21 Oct 2005 14:34:26 +0200 (CEST) Subject: Re: Postgres 7.4.9 slow! From: Mario Splivalo Reply-To: mario.splivalo@mobart.hr To: =?ISO-8859-1?Q?Havasv=F6lgyi_Ott=F3?= Cc: pgsql-sql@postgresql.org In-Reply-To: <006701c5d637$2d7b5550$6400a8c0@OTTO> References: <1129893226.25351.3.camel@ekim> <006701c5d637$2d7b5550$6400a8c0@OTTO> Content-Type: text/plain; charset=UTF-8 Organization: Mob-Art Date: Fri, 21 Oct 2005 14:34:26 +0200 Message-Id: <1129898066.27326.6.camel@ekim> Mime-Version: 1.0 X-Mailer: Evolution 2.4.1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by OpenSource AV+AS Mail Server X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 required=5 tests=[AWL=0.006] X-Spam-Level: X-Archive-Number: 200510/240 X-Sequence-Number: 23093 On Fri, 2005-10-21 at 14:01 +0200, Havasvölgyi Ottó wrote: > Mike, > > Please send the EXPLAIN ANALYZE of the two versions of the query. There they are, they are both the same: join_test=# select version(); version ---------------------------------------------------------------------------------------------------------------------- PostgreSQL 7.4.9 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9) (1 row) join_test=# \timing Timing is on. join_test=# set enable_seqscan to off; SET Time: 0.715 ms join_test=# explain select p.phone, count(*) from phones p left join table_data d on p.phone = d.phone group by p.phone having count(*) > 1 order by count(*) desc; QUERY PLAN --------------------------------------------------------------------------------------------------------------------- Sort (cost=4993545.35..4993754.61 rows=83704 width=16) Sort Key: count(*) -> GroupAggregate (cost=0.00..4985814.87 rows=83704 width=16) Filter: (count(*) > 1) -> Merge Left Join (cost=0.00..4974843.57 rows=1379136 width=16) Merge Cond: (("outer".phone)::text = ("inner".phone)::text) -> Index Scan using pk1 on phones p (cost=0.00..2876.37 rows=83704 width=16) -> Index Scan using "fki_fkTableData" on table_data d (cost=0.00..4954515.15 rows=1379135 width=16) (8 rows) Time: 169.781 ms join_test=# And now the 7.4.8: join_test=# select version(); version -------------------------------------------------------------------------------------------------- PostgreSQL 7.4.8 on i686-pc-linux-gnu, compiled by GCC gcc (GCC) 3.3.5 (Debian 1:3.3.5-8ubuntu2) (1 row) join_test=# \timing Timing is on. join_test=# set enable_seqscan to off; SET Time: 0.500 ms join_test=# explain select p.phone, count(*) from phones p left join table_data d on p.phone = d.phone group by p.phone having count(*) > 1 order by count(*) desc; QUERY PLAN --------------------------------------------------------------------------------------------------------------------- Sort (cost=4993545.35..4993754.61 rows=83704 width=16) Sort Key: count(*) -> GroupAggregate (cost=0.00..4985814.87 rows=83704 width=16) Filter: (count(*) > 1) -> Merge Left Join (cost=0.00..4974843.57 rows=1379136 width=16) Merge Cond: (("outer".phone)::text = ("inner".phone)::text) -> Index Scan using pk1 on phones p (cost=0.00..2876.37 rows=83704 width=16) -> Index Scan using "fki_fkTableData" on table_data d (cost=0.00..4954515.15 rows=1379135 width=16) (8 rows) Time: 31.510 ms join_test=# The plans are same. It's just that when I run the query with pg7.4.8 it takes 100% of the processor time while running. pg7.4.9 takes 2-10% while running. Disk activity is much more intense with pg7.4.9 Mike -- Mario Splivalo Mob-Art mario.splivalo@mobart.hr "I can do it quick, I can do it cheap, I can do it well. Pick any two."