Re: [PERFORM] Re: Query > 1000× slowdown after adding datetime comparison

From: Stefan Keller <sfkeller(at)gmail(dot)com>
To: twoflower <standa(dot)kurik(at)gmail(dot)com>
Cc: "pgsql-performance(at)postgresql(dot)org" <pgsql-performance(at)postgresql(dot)org>
Subject: Re: [PERFORM] Re: Query > 1000× slowdown after adding datetime comparison
Date: 2015-08-31 20:24:35
Message-ID: CAFcOn2-u8QE-0vwkUuEQ7b1m9+YfH=vjLAaJrhAh=zU4n9Hu1w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

2015-08-31 21:46 GMT+02:00 twoflower <standa(dot)kurik(at)gmail(dot)com> wrote:
> I created a new boolean column and filled it for every row in DOCUMENT with
> *(doc.date_last_updated >= date(now() - '171:00:00'::interval))*, reanalyzed
> ...

... and you've put an index on that new boolean column (say "updated")?
CREATE INDEX index_name ON some_table (boolean_field);
or tried a conditional index like
CREATE INDEX index_name ON some_table (some_field) WHERE boolean_field;

-S.

2015-08-31 21:46 GMT+02:00 twoflower <standa(dot)kurik(at)gmail(dot)com>:
> David G Johnston wrote
>> What happens if you pre-compute the date condition and hard code it?
>
> I created a new boolean column and filled it for every row in DOCUMENT with
> *(doc.date_last_updated >= date(now() - '171:00:00'::interval))*, reanalyzed
> the table and modified the query to just compare this column to TRUE. I
> expected this to be very fast, considering that a (to me, anyway) similar
> query also containing a constant value comparison finishes immediately.
> However, the query is running now for 4 minutes already. That's really
> interesting.
>
>
>
> --
> View this message in context: http://postgresql.nabble.com/Query-1-000-000-slowdown-after-adding-datetime-comparison-tp5864045p5864088.html
> Sent from the PostgreSQL - performance mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-performance mailing list (pgsql-performance(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-performance

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message twoflower 2015-08-31 20:30:41 Re: Re: Query > 1000× slowdown after adding datetime comparison
Previous Message twoflower 2015-08-31 19:46:56 Re: Re: Query > 1000× slowdown after adding datetime comparison