"Worky Workerson" <worky.workerson@xxxxxxxxx> writes: > -> Index Scan using ip_profiles_pkey on ip_profiles > (cost=0.00..3.37 rows=1 width=4) (actual time=0.035..1195.567 > rows=144445 loops=1) > Index Cond: ((ip > '1.0.0.0'::ip4) AND (ip <= '1.255.255.255)) Um ... have you ANALYZEd these tables recently? If so, try increasing the statistics target for them. You aren't ever going to get decent plans when the rowcount estimates are off by five orders of magnitude, and for such a simple condition I see no reason why they would be except for obsolete or inadequate stats. regards, tom lane