pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Index degradation
2+ messages / 2 participants
[nested] [flat]

* Index degradation
@ 2019-11-07 19:33  Alex Balashov <abalashov@evaristesys.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Alex Balashov @ 2019-11-07 19:33 UTC (permalink / raw)
  To: pgsql-admin

Over a period of some years, particularly in tables whose contents
periodically get swapped out entirely (i.e. lots of dead rows), indexes
slowly degrade, pushing query latency up. 

Is there a way to detect this condition short of just monitoring
statement latency, so as to know when to REINDEX / build new indexes?

-- 
Alex Balashov | Principal | Evariste Systems LLC

Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free) 
Web: http://www.evaristesys.com/, http://www.csrpswitch.com/





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Index degradation
@ 2019-11-07 20:26  Keith Fiske <keith.fiske@crunchydata.com>
  parent: Alex Balashov <abalashov@evaristesys.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Keith Fiske @ 2019-11-07 20:26 UTC (permalink / raw)
  To: Alex Balashov <abalashov@evaristesys.com>; +Cc: pgsql-admin

This sounds like index bloat, and yes you can monitor for it. I've written
some blog posts both on detection and cleanup procedures as well as been
working on a tool to make monitoring for it easier.

https://www.keithf4.com/checking-for-postgresql-bloat/
https://www.keithf4.com/cleaning-up-postgresql-bloat/
https://github.com/keithf4/pg_bloat_check

Also, to help mitigate this problem in the future, you can try and tune
autovacuum to run on said tables so that space is marked as reusable on a
regular enough basis that new inserts/updates can make use of it more
efficiently. The following blog post talks about how to tune autovacuum for
wrap-around, but this is applicable to tuning it to avoid bloat as well.
Note this only really helps with gradual changes to tables. Sudden large
purging of a table with deletes, or mass updates, are going to leave more
empty space that autovacuum can really be tuned for. In such cases, you
should always follow up said operations with a manual vacuum and bloat
cleanup as needed.

https://www.keithf4.com/per-table-autovacuum-tuning/

Hope that helps!



On Thu, Nov 7, 2019 at 2:33 PM Alex Balashov <abalashov@evaristesys.com>
wrote:

> Over a period of some years, particularly in tables whose contents
> periodically get swapped out entirely (i.e. lots of dead rows), indexes
> slowly degrade, pushing query latency up.
>
> Is there a way to detect this condition short of just monitoring
> statement latency, so as to know when to REINDEX / build new indexes?
>
> --
> Alex Balashov | Principal | Evariste Systems LLC
>
> Tel: +1-706-510-6800 / +1-800-250-5920 (toll-free)
> Web: http://www.evaristesys.com/, http://www.csrpswitch.com/
>
>
>

-- 
Keith Fiske
Senior Database Engineer
Crunchy Data - http://crunchydata.com

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2019-11-07 20:26 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-11-07 19:33 Index degradation Alex Balashov <abalashov@evaristesys.com>
2019-11-07 20:26 ` Keith Fiske <keith.fiske@crunchydata.com>

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