pg_stats.correlation rule of thumb for re-clustering a table?

From: Ron Johnson <ronljohnsonjr(at)gmail(dot)com>
To: pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: pg_stats.correlation rule of thumb for re-clustering a table?
Date: 2025-09-12 14:46:30
Message-ID: CANzqJaCEvOm_zY7Ex_vN3r5cQLzWx9DxYd3hV=pwPmm4wsJGWQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-admin

(By re-cluster, I of course mean pg_repack.)

Purely OLTP tables (that are only accessed randomly) can of course live
with 0% correlation, but lots of tables are mixed-use, and so benefit from
physical ordering on a carefully chosen field..

SELECT abs(correlation)::numeric(3,2) as correlation
FROM pg_stats
WHERE schemaname = 'foo' AND tablename = 'bar'
AND attname = 'blarge';
correlation
-------------
0.84
(1 row)

Obviously 84% is no need to worry, but what about 60% or 40%? Currently, I
use 60%, but would like to do better.

--
Death to <Redacted>, and butter sauce.
Don't boil me, I'm still alive.
<Redacted> lobster!

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Laurenz Albe 2025-09-12 20:59:07 Re: pg_stats.correlation rule of thumb for re-clustering a table?
Previous Message Laurenz Albe 2025-09-12 05:26:08 Re: Pgbouncer