Yet another slow join query..

From: Rajesh Kumar Mallah <mallah(at)trade-india(dot)com>
To: pgsql-performance(at)postgresql(dot)org
Subject: Yet another slow join query..
Date: 2003-07-18 12:51:21
Message-ID: 200307181821.21329.mallah@trade-india.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

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)

-----------------------------------------

Any help is appreciated.

Regds
mallah.

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Tom Lane 2003-07-18 13:24:58 Re: index / sequential scan problem
Previous Message Andrew Sullivan 2003-07-18 11:34:40 Re: Clearing rows periodically