Chris Kratz wrote: > Unfortunately, if I don't think the sorting idea would help in the one case > I'm looking at which involves filters on two tables that are joined > together. The filters happen to be correlated such that about 95% of the > rows from each filtered table are actually returned after the join. > Unfortunately, the planner thinks we will get 1 row back. Maybe you can wrap that part of the query in a SQL function and set its estimated cost to the real values with ALTER FUNCTION ... ROWS. -- Alvaro Herrera http://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support