And another thing which comes out as a little surprising to me - if I replace the *date_last_updated* condition with another one, say *doc.documenttype = 4*, the query finishes immediately. *documenttype* is an unindexed integer column. Here's the query plan: <http://postgresql.nabble.com/file/n5864080/qp3.png> What's so special about that *date_last_updated* condition that makes it so slow to use? Is it because it involves the *date()* function call that it makes it difficult for the planner to guess the data distribution in the DOCUMENT table? -- View this message in context: http://postgresql.nabble.com/Query-1-000-000-slowdown-after-adding-datetime-comparison-tp5864045p5864080.html Sent from the PostgreSQL - performance mailing list archive at Nabble.com. -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance