Re: BRIN index which is much faster never chosen by planner - Mailing list pgsql-hackers

From Michael Lewis
Subject Re: BRIN index which is much faster never chosen by planner
Date
Msg-id CAHOFxGq7AQuMALi-ZH+4sRLKfLJ2-KzXRu3WVwM1fZzzhtCBpA@mail.gmail.com
Whole thread Raw
In response to Re: BRIN index which is much faster never chosen by planner  (Jeremy Finzel <finzelj@gmail.com>)
Responses Re: BRIN index which is much faster never chosen by planner
List pgsql-hackers
Thanks for closing the loop on the data correlation question. I've been playing with BRIN indexes on a log table of sorts and this thread helped clear up some of the behavior I have been seeing.

I am curious, would a partial btree index fit your needs? Perhaps the maintenance overhead is too significant or this is too off-the-wall, but a daily job to create new index and drop the old concurrently could give the performance you need while still saving the extra disk space of the full btree on the timestamp.

CREATE INDEX CONCURRENTLY log_table_rec_insert_time_partial_10_04 ON log_table USING btree ( rec_insert_time ) WHERE rec_insert_time > '2019-10-04'::DATE;
DROP INDEX CONCURRENTLY IF EXISTS log_table_rec_insert_time_partial_10_03;

I would consider including category column as well, but I suspect that would increase the size of the index significantly. Of course, this depends on the query planner evaluating that "l.rec_insert_time >= now() - interval '10 days'" and determining that the index fulfills the need.

pgsql-hackers by date:

Previous
From: Justin Pryzby
Date:
Subject: v12.0: interrupt reindex CONCURRENTLY: ccold: ERROR: could not findtuple for parent of relation ...
Next
From: vignesh C
Date:
Subject: Re: Ordering of header file inclusion