Jeff Cole <cole.jeff@xxxxxxxxx> writes: > Hi, I'm new to tuning PostgreSQL and I have a query that gets slower > after I run a vacuum analyze. I believe it uses a Hash Join before > the analyze and a Nested Loop IN Join after. It seems the Nested > Loop IN Join estimates the correct number of rows, but underestimates > the amount of time required. I am curious why the vacuum analyze > makes it slower and if that gives any clues as too which parameter I > should be tuning. Hm, the cost for the upper nestloop is way less than you would expect given that the HASH IN join is going to have to be repeated 100+ times. I think this must be due to a very low "join_in_selectivity" estimate but I'm not sure why you are getting that, especially seeing that the rowcount estimates aren't far off. Can you show us the pg_stats rows for symptoms.id and symptom_reports.symptom_id? regards, tom lane