X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id CE286D6FD0 for ; Fri, 2 Sep 2005 00:20:10 -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 19945-10 for ; Fri, 2 Sep 2005 03:20:05 +0000 (GMT) Received: from linda-2.paradise.net.nz (bm-2a.paradise.net.nz [202.0.58.21]) by svr1.postgresql.org (Postfix) with ESMTP id 9ABE4D6DF4 for ; Fri, 2 Sep 2005 00:20:01 -0300 (ADT) Received: from smtp-1.paradise.net.nz (smtp-1a.paradise.net.nz [202.0.32.194]) by linda-2.paradise.net.nz (Paradise.net.nz) with ESMTP id <0IM60080G6L7FY@linda-2.paradise.net.nz> for pgsql-performance@postgresql.org; Fri, 02 Sep 2005 15:19:56 +1200 (NZST) Received: from [192.168.1.11] (218-101-45-29.paradise.net.nz [218.101.45.29]) by smtp-1.paradise.net.nz (Postfix) with ESMTP id 746BE82A15; Fri, 02 Sep 2005 15:19:55 +1200 (NZST) Date: Fri, 02 Sep 2005 15:19:53 +1200 From: Mark Kirkwood Subject: Re: Massive performance issues In-reply-to: <20050901174231.GE23970@pongo.lshift.net> To: Matthew Sackman Cc: pgsql-performance@postgresql.org Message-id: <4317C4D9.9070106@paradise.net.nz> MIME-version: 1.0 Content-type: text/plain; format=flowed; charset=ISO-8859-1 Content-transfer-encoding: 7bit X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0.6 (X11/20050726) References: <20050901174231.GE23970@pongo.lshift.net> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.14 required=5 tests=[AWL=0.140] X-Spam-Level: X-Archive-Number: 200509/40 X-Sequence-Number: 14348 It would be good to see EXPLAIN ANALYZE output for the three queries below (the real vs. estimated row counts being of interest). The number of pages in your address table might be interesting to know too. regards Mark Matthew Sackman wrote (with a fair bit of snippage): > explain select locality_2 from address where locality_2 = 'Manchester'; > gives > QUERY PLAN > ---------------------------------------------------------------- > Seq Scan on address (cost=0.00..80677.16 rows=27923 width=12) > Filter: ((locality_2)::text = 'Manchester'::text) > > > explain select locality_1 from address where locality_1 = 'Manchester'; > gives > QUERY PLAN > ---------------------------------------------------------------- > Index Scan using address_locality_1_index on address > (cost=0.00..69882.18 rows=17708 width=13) > Index Cond: ((locality_1)::text = 'Manchester'::text) > > > select street, locality_1, locality_2, city from address > where (city = 'Nottingham' or locality_2 = 'Nottingham' > or locality_1 = 'Nottingham') > and upper(substring(street from 1 for 1)) = 'A' > group by street, locality_1, locality_2, city > order by street > limit 20 offset 0 >