Why is seq search preferred here by planner? - Mailing list pgsql-sql

From
Subject Why is seq search preferred here by planner?
Date
Msg-id 1220.219.65.235.51.1051114881.squirrel@mail.trade-india.com
Whole thread Raw
Responses Re: Why is seq search preferred here by planner?  (Josh Berkus <josh@agliodbs.com>)
List pgsql-sql
Hi Folks,

I want to update the country feild in table email_bank by looking
up another table personal_account_details by matching userid.
any anyone tellme why an seq scan on personal_account_details
for getting the coutry. the query is:

UPDATE email_bank set country=personal_account_details.country where userid > 0 and
userid=personal_account_details.userid  ;

both tables have been vacuum analyzed before running the queries.
my question is is the the best plan ?

becoz i most get similar plan when i update in
this manner.

Its quite a decent IBM xseries server with
2GB ram   and 4  Intel(R) XEON(TM) CPU 2.00GHz.


and explain analyze is below:

tradein_clients=# begin work;explain analyze UPDATE email_bank set
country=personal_account_details.country where userid > 0 and
userid=personal_account_details.userid  ;BEGIN
Time: 669.57 ms
                                                                 QUERY PLAN

----------------------------------------------------------------------------------------------------------------------------------------------
HashJoin  (cost=14496.79..36722.98 rows=216658 width=137) (actual time=3505.31..49707.67rows=150756 loops=1)   Hash
Cond:("outer".userid = "inner".userid)  ->  Seq Scan on email_bank  (cost=0.00..16268.10 rows=216658 width=123) (actual
time=0.06..43033.91 rows=155714 loops=1)         Filter: (userid > 0)  ->  Hash  (cost=14113.23..14113.23 rows=153423
width=14)(actual time=3505.08..3505.08 rows=0  loops=1)         ->  Seq Scan on personal_account_details
(cost=0.00..14113.23rows=153423 width=14)        (actual time=0.04..3196.12 rows=153431 loops=1) Total runtime:
209472.14msec 
(7 rows)

Regds
Mallah.



-----------------------------------------
Get your free web based email at trade-india.com.  "India's Leading B2B eMarketplace.!"
http://www.trade-india.com/



pgsql-sql by date:

Previous
From: Jeff Eckermann
Date:
Subject: Re: how to put an special code in a string
Next
From: Josh Berkus
Date:
Subject: Re: Why is seq search preferred here by planner?