Re: index fragmentation on insert-only table with non-unique column - Mailing list pgsql-performance

From Justin Pryzby
Subject Re: index fragmentation on insert-only table with non-unique column
Date
Msg-id 20160525134524.GA21220@telsasoft.com
Whole thread Raw
In response to Re: index fragmentation on insert-only table with non-unique column  (Peter Geoghegan <pg@bowt.ie>)
List pgsql-performance
On Tue, May 24, 2016 at 09:16:20PM -0700, Peter Geoghegan wrote:
> On Tue, May 24, 2016 at 10:39 AM, Justin Pryzby <pryzby@telsasoft.com> wrote:
> > Postgres seems to assume that the high degree of correlation of the table
> > column seen in pg_stats is how it will get data from the index scan, which
> > assumption seems to be very poor on what turns out to be a higly fragmented
> > index.  Is there a way to help it to understand otherwise??
>
> Your complaint is vague. Are you complaining about the planner making
> a poor choice? I don't think that's the issue here, because you never
> made any firm statement about the planner making a choice that was
> worth than an alternative that it had available.

I was thinking there a few possible places to make improvements: the planner
could have understood that scans of non-unique indices don't result in strictly
sequential scans of the table, the degree of non-sequentialness being
determined by the column statistics, and perhaps by properties of the index
itself.

Or the INSERT code or btree scan could improve on this, even if tuples aren't
fully ordered.

> If you're arguing for the idea that B-Trees should reliably keep
> tuples in order by a tie-break condition, that seems difficult to
> implement, and likely not worth it in practice.

I had the awful idea to change the index to use (recordopeningtime,ctid).
Maybe somebody will convince me otherwise, but may actually work better than
trying to reindex this table daily by 4am.

Thanks,
Justin


pgsql-performance by date:

Previous
From: Jeff Janes
Date:
Subject: Re: index fragmentation on insert-only table with non-unique column
Next
From: Justin Pryzby
Date:
Subject: Re: index fragmentation on insert-only table with non-unique column