Re: Updating histogram_bounds after a delete - Mailing list pgsql-performance

From Derrick Rice
Subject Re: Updating histogram_bounds after a delete
Date
Msg-id AANLkTikrVqwXp3ugoMLR8-6BOegSDByRCuTCFtGVBZ+E@mail.gmail.com
Whole thread Raw
In response to Re: Updating histogram_bounds after a delete  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
Responses Re: Updating histogram_bounds after a delete  ("Kevin Grittner" <Kevin.Grittner@wicourts.gov>)
List pgsql-performance
On Wed, Mar 16, 2011 at 5:56 PM, Kevin Grittner <Kevin.Grittner@wicourts.gov> wrote:
there is a feature to probe the end of an index's range in
situations where data skew was often causing less than optimal plans
to be chosen.

Was this introduced in 9.0 or was it earlier?  My company hasn't introduced integrated support for 9.0 yet, but I can go to 8.4.

It was suggested that I change my SQL from:

delete from my_table where event_date < now() - interval '12 hours';

to:

delete from my_table where event_date < now() - interval '12 hours'
and event_date >= (select min(event_date) from my_table);

Which, even if the stats are out of date, will be more accurate as it will not consider the histogram buckets that are empty due to previous deletes.  Seems like exactly what the feature you mentioned would do, no?

Thanks for the help,

Derrick

pgsql-performance by date:

Previous
From: Tech Madhu
Date:
Subject: Re: pg_xlog size
Next
From: "Kevin Grittner"
Date:
Subject: Re: Updating histogram_bounds after a delete