Prasanth <dbadmin@xxxxxxxxxxx> writes: > Hash Join (cost=13865.30..326413.23 rows=6451 width=18) > Hash Cond: ("outer".id = "inner".id) > -> Seq Scan on a (cost=0.00..125076.37 rows=6450937 width=18) > -> Hash (cost=10168.64..10168.64 rows=500664 width=4) > -> Seq Scan on b (cost=0.00..10168.64 rows=500664 width=4) > (5 rows) > The planner used to perform a index scan. I have added a lot of data in those > two tables. Right now both tables have millions of records. It is highly unlikely that you want an index scan for joining millions of records ... However, if you do have millions in both tables, why does the planner think there are only 500664 rows in b? Maybe you are overdue for ANALYZE. regards, tom lane