It seems like your row estimate are way off, with the planner expecting 1 and getting 3000 or so. Have you tried cranking up default stats target to say 1000, running analyze and seeing what happens? If that doesn't do it, try temporarily turning off nested loops: set enable_nestloop = off; explain analyze yourqueryhere; -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance