Actually most of the estimates seem pretty good. There are some that are a ways off, but the real nasties seem to be these. I'm a bit confused because it looks like two of your joins don't have Join Filters -- and one of those is a left join for which I thought that was impossible. Are you sure this query is doing what you expect? You have add_missing_from enabled which will happily bring in additional joins if you reference a table which isn't already included in the join and do a full cartesian-product join. -> Nested Loop Left Join (cost=145.04..2381.33 rows=1 width=74) (actual time=38.955..9678.057 rows=3754 loops=1) Join Filter: ((c.partid = e.partid) AND leadcompcheck_ab(a.leadfree, c.leadstateid)) -> Nested Loop (cost=145.04..2366.26 rows=1 width=62) (actual time=0.791..83.482 rows=3754 loops=1) -> Nested Loop Left Join (cost=145.04..2365.59 rows=1 width=28) (actual time=0.721..52.840 rows=3754 loops=1) Filter: (f.commited IS NOT TRUE) -- greg http://mit.edu/~gsstark/resume.pdf -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general