So, if I'm understanding you correctly, we're talking solely about following clause in the query you gave initially: WHERE doc.date_last_updated >= date(now() - '171:00:00'::interval) which initially was WHERE documenttype = 4 and now is being replaced by a temporary (I'd say derived) column WHERE updated ? In any case - I have to go - but run http://explain.depesz.com/ and give a weblink to the explain plans of your queries. -S. 2015-08-31 22:30 GMT+02:00 twoflower <standa.kurik@xxxxxxxxx>: > I did not. I wanted to compare this query to the one I tried before, having > *documenttype = 4* as the sole condition. That one was very fast and the > *documenttype* was not indexed either. > > But this query, using the new temporary column, still runs, after 48 > minutes... > > > > -- > View this message in context: http://postgresql.nabble.com/Query-1-000-000-slowdown-after-adding-datetime-comparison-tp5864045p5864101.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 -- Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance