From: Gavin Flower <GavinFlower@archidevsys.co.nz>
To: pgsql-general@lists.postgresql.org
Subject: Re: Question about behavior of conditional indexes
Date: Tue, 21 Sep 2021 23:14:32 +1200
Message-ID: <a40fa39e-2edd-a9e3-ebee-f9a555f6eb89@archidevsys.co.nz> (raw)
In-Reply-To: <CAGbX52Fitf7BUhfDGzzasxv31WM3EOmdfhaYdcUKkNajixau0A@mail.gmail.com>
References: <CAGbX52Fitf7BUhfDGzzasxv31WM3EOmdfhaYdcUKkNajixau0A@mail.gmail.com>
On 21/09/21 22:28, Koen De Groote wrote:
> Greetings all,
>
> Working on postgres 11.
>
> I'm researching an index growing in size and never shrinking, and not
> being used anymore after a while.
>
> The index looks like this:
>
> |"index002" btree (action_performed, should_still_perform_action,
> action_performed_at DESC) WHERE should_still_perform_action = false
> AND action_performed = true |
> So, there are 2 boolean fields, and a conditional clause for both. The
> table has about 50M rows, the index barely ever goes over 100K matched
> rows.
>
> The idea is to search for rows matching these conditions quickly, and
> then update them. This happens daily.
>
> This means the condition no longer match the index. At this point,
> does the row get removed from the index? Or does it stay in there as a
> dead row?
>
> I'm noticing index bloat on this index and am wondering if all these
> updated rows just stay in the index?
>
> The index currently sits at 330MB. If I drop and re-create it, it's 1.5MB.
>
> A cronjob runs a vacuum once per day, I can see the amount of dead
> rows dropping in monitoring software.
>
> But should this also take care of indexes? In postgres 11, you can't
> reindex concurrently, so I was wondering if indexes are skipped by
> vacuum? Or only in case of conditional indexes?
>
>
>
> So I'm wondering if the behavior is as I described.
>
> Regards,
> Koen De Groote
Can you upgrade to pg13? A lot of work was done on indexes in pg12 &
13. So possibly your problem may have been resolved, at least in part.
Note that pg 14 is due out this month.
Cheers,
Gavin
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: GavinFlower@archidevsys.co.nz
Subject: Re: Question about behavior of conditional indexes
In-Reply-To: <a40fa39e-2edd-a9e3-ebee-f9a555f6eb89@archidevsys.co.nz>
References: <CAGbX52Fitf7BUhfDGzzasxv31WM3EOmdfhaYdcUKkNajixau0A@mail.gmail.com> <a40fa39e-2edd-a9e3-ebee-f9a555f6eb89@archidevsys.co.nz>
* 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