David Osborne <david@xxxxxxxxxxx> writes: > Hi, I was wondering if someone could help us work out why this query is so > slow. > We've just dumped a database (Postgresql 9.1) and restored it to a new > instance (AWS RDS 9.6) (via pg_dump, restored to psql) The first question people will ask is did you re-ANALYZE the new database? pg_dump doesn't take care of that for you, and auto-analyze might not think it needs to process the smaller tables. regards, tom lane