pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tom Dearman <tom.dearman@gmail.com>
Cc: Michael Lewis <mlewis@entrata.com>
Cc: Peter Geoghegan <pg@bowt.ie>
Cc: pgsql-general General <pgsql-general@postgresql.org>
Subject: Re: Frequetly updated partial index leads to bloat on index for Postresql 11
Date: Fri, 16 Jul 2021 11:43:35 -0400
Message-ID: <3738900.1626450215@sss.pgh.pa.us> (raw)
In-Reply-To: <F84B8181-F681-407C-ABFF-894791C19B7C@gmail.com>
References: <CAGRwtPy0stc_XSuWdxis7GtvVUV2=xWjsd-g4hjzOSaTi5L72A@mail.gmail.com>
	<CAH2-WzmoZBJXYcaBKt2Zjyy-RXiHRsCQyXTcZKiB+n1C4kteTw@mail.gmail.com>
	<95D506BA-D1E8-45BB-8167-BD61ED3D9B9C@gmail.com>
	<CAHOFxGqP_SgWhZ7ZAts8DMQTKdP_7=T0XJiF2XosZJJWii84+g@mail.gmail.com>
	<F84B8181-F681-407C-ABFF-894791C19B7C@gmail.com>

Tom Dearman <tom.dearman@gmail.com> writes:
> We have change autovacuum so that it runs more frequently autovacuum_vacuum_scale_factor=0.035, the reason we have a partial index on the status is that in a table of 300 million entries, only about 100 or so would have status=‘IN_PROGRESS’ so we think this should be a nice small index and many of our queries want to look up with a where clause status=‘IN_PROGRESS’.  In theory it works well, but we get a lot of index bloat as there is a lot of churn on the status value, ie each row starts as IN_PROGRESS and then goes to one of 4 possible completed statuses. 

Is it really the case that only this index is bloating?  In principle, an
update on a row of the table should result in new entries in every index
of the table.  A partial index, due to the filter applied to possibly not
store any index entry, should in theory have less bloat than other
indexes.

If that's not what you're seeing, there must be something about the data
being stored in that index (not the partial-index filter condition) that
results in a lot of low-occupancy index pages over time.  You didn't say
anything about what the data payload is.  But we've seen bloat problems in
indexes where, say, every tenth or hundredth value in the index ordering
would persist for a long time while the ones in between get deleted
quickly.  That leads to low-density indexes that VACUUM can't do anything
about.

			regards, tom lane





view thread (10+ messages)  latest in thread

Message-ID: <3738900.1626450215@sss.pgh.pa.us>
Permalink:  ../3738900.1626450215@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3738900.1626450215@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, tom.dearman@gmail.com, mlewis@entrata.com, pg@bowt.ie
  Subject: Re: Frequetly updated partial index leads to bloat on index for Postresql 11
  In-Reply-To: <3738900.1626450215@sss.pgh.pa.us>
  References: <CAGRwtPy0stc_XSuWdxis7GtvVUV2=xWjsd-g4hjzOSaTi5L72A@mail.gmail.com> <CAH2-WzmoZBJXYcaBKt2Zjyy-RXiHRsCQyXTcZKiB+n1C4kteTw@mail.gmail.com> <95D506BA-D1E8-45BB-8167-BD61ED3D9B9C@gmail.com> <CAHOFxGqP_SgWhZ7ZAts8DMQTKdP_7=T0XJiF2XosZJJWii84+g@mail.gmail.com> <F84B8181-F681-407C-ABFF-894791C19B7C@gmail.com> <3738900.1626450215@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox