Charles Hauser <chauser@duke.edu> writes:
> I have the following query which is running quite slow on our server and
> was hoping someone would have suggestions how I might improve it.
Have you vacuumed or analyzed these tables recently? The EXPLAIN
numbers show that the planner thinks all the tables are tiny, which
hardly seems likely given that you're complaining about the speed.
If it's still bad after you VACUUM ANALYZE, send EXPLAIN ANALYZE (not
just EXPLAIN) output and maybe we can give some help.
regards, tom lane