From: | Keith Fiske <keith(dot)fiske(at)crunchydata(dot)com> |
---|---|
To: | Victor Sudakov <vas(at)sibptus(dot)ru> |
Cc: | Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org> |
Subject: | Re: index bloat estimation |
Date: | 2021-02-12 15:30:21 |
Message-ID: | CAODZiv6YZj3GJsTv5_dp07VS2FACrFu_JPWsFVi64=1mJD_t0A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
On Fri, Feb 12, 2021 at 3:26 AM Victor Sudakov <vas(at)sibptus(dot)ru> wrote:
> Dear Colleagues,
>
> What queries do you use to estimate index and table bloat?
>
> I've researched some on the Net and found multiple scripts mentioned in
> https://wiki.postgresql.org/wiki/Index_Maintenance#Index_Bloat, also
> in https://github.com/pgexperts/pgx_scripts etc.
>
> Most of the stuff I've looked at is pretty old, much seems unsupported.
> What is the current best practice?
>
> I'd be grateful if you could share your personal favourite ways of
> estimating bloat.
>
> --
> Victor Sudakov, VAS4-RIPE, VAS47-RIPN
> 2:5005/49(at)fidonet http://vas.tomsk.ru/
>
>
>
Why estimate when you can get the exact amount? At least for b-tree indexes
anyway.
https://github.com/keithf4/pg_bloat_check
This script uses the pgstattuple extension to get both table and b-tree
index bloat information. Since it's actually scanning the table, it can
take longer than other queries that try and do estimates based on
statistics. But it does give you very accurate information. You can also
just use pgstattuple directly without this script, but you do have to run
it individually on the table then each index. The script can scan the table
and all its indexes in one step and give you a full summary.
https://www.postgresql.org/docs/13/pgstattuple.html
--
Keith Fiske
Senior Database Engineer
Crunchy Data - http://crunchydata.com
From | Date | Subject | |
---|---|---|---|
Next Message | jian xu | 2021-02-12 21:16:23 | pg13 psql can't connect pg instance with ssl enabled after upgrading |
Previous Message | Guillaume Lelarge | 2021-02-12 09:03:36 | Re: index bloat estimation |