X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.192]) by svr1.postgresql.org (Postfix) with ESMTP id 277C7CCD6A for ; Fri, 18 Jul 2003 16:09:02 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr4.postgresql.org [64.117.224.192]) (amavisd-new, port 10024) with ESMTP id 65795-06 for ; Fri, 18 Jul 2003 16:09:33 +0000 (GMT) Received: from megazone.bigpanda.com (unknown [66.180.233.26]) by svr1.postgresql.org (Postfix) with ESMTP id 9BB4ACCD62 for ; Fri, 18 Jul 2003 13:08:59 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 26E01D615; Fri, 18 Jul 2003 09:09:32 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 1C8715C10; Fri, 18 Jul 2003 09:09:32 -0700 (PDT) Date: Fri, 18 Jul 2003 09:09:31 -0700 (PDT) From: Stephan Szabo To: Rajesh Kumar Mallah Cc: Subject: Re: Yet another slow join query.. In-Reply-To: <200307181821.21329.mallah@trade-india.com> Message-ID: <20030718090729.Y95696-100000@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/297 X-Sequence-Number: 2590 On Fri, 18 Jul 2003, Rajesh Kumar Mallah wrote: > Hi All, > > data_bank.updated_profiles and public.city_master are small tables > with 21790 and 49303 records repectively. both have indexes on the join > column. in first one on (city,source) and in second one on (city) > > The query below does not return for long durations > 10 mins. > > explain analyze select b.state,a.city from data_bank.updated_profiles a join > public.city_master b using(city) where source='BRANDING' and a.state is NULL > and b.country='India' ; > > > simple explain returns below. > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Nested Loop (cost=0.00..83506.31 rows=14 width=35) > Join Filter: ("outer".city = ("inner".city)::text) > -> Seq Scan on updated_profiles a (cost=0.00..1376.39 rows=89 width=11) > Filter: ((source = 'BRANDING'::character varying) AND (state IS NULL)) > -> Index Scan using city_master_temp1 on city_master b (cost=0.00..854.87 > rows=5603 width=24) > Filter: (country = 'India'::character varying) > (6 rows) How many rows actually meet the filter conditions on updated_profiles and city_master? Are the two city columns of the same type?