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/