Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uxArT-00BcQj-82 for pgsql-admin@arkaria.postgresql.org; Fri, 12 Sep 2025 20:59:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uxArQ-003x4L-8U for pgsql-admin@arkaria.postgresql.org; Fri, 12 Sep 2025 20:59:13 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uxArP-003x4A-Rl for pgsql-admin@lists.postgresql.org; Fri, 12 Sep 2025 20:59:12 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uxArM-000UBu-1p for pgsql-admin@postgresql.org; Fri, 12 Sep 2025 20:59:12 +0000 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-3e07ffffb87so1310844f8f.2 for ; Fri, 12 Sep 2025 13:59:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1757710748; x=1758315548; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=LbPkKxMtP8VGS/YtG/uNirS+Yl1jcmOPyyTtfqW676Q=; b=CgSl13mktULdtORAOcAj6gFyltllHw7Dq6G2ejYA8/50BjL8LV7Jx/JwQw/aGc5de/ e8mdct7+pBs+uu19RZccdYN7fhF+MsTLrOadPDA/52haJv4CctfzzU0M4+TNxMw8vnj8 jzun6IgLj/M0BkIIpW/RncpFQQEfQn7MTLAkBRJ+KON/W+iDtiAWtQWZ825IIFGVIWV5 /0sJd3aAfywq5pggdUdSwrxa0pbnEuB800+vnEQf5R2E81wWcRlf47Km6Ph7zeUCLyph TuQ+A2dTeKJAgap9Xw6hYZYbNXg7jI+D1Z1kHtqTluKoR6BZahvBmOgY1/8v0p3XpZiW 5bKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757710748; x=1758315548; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=LbPkKxMtP8VGS/YtG/uNirS+Yl1jcmOPyyTtfqW676Q=; b=NojoEhuIRCe5t194xal+PCqitjMb+uD6OJBfUBS2R4MWluoVB/RXqxW30PB18bDWaw YJ+9briJNhRufYG5PmtzpY+zqVH3teAzZmuxM5b1gWNlNfmpCVYqr2QDbAtkUk3YZ3Dy eT+L4nzC7iNh4Lstcbyr6ERtlGBdpF934KWipEcrGC5B/5UIiuZxdXpp2Szm9coYlZ4w n1JoWb/4A5MhqgCn5iTijVm+yCMIzfJVI5UP1ZPSFBr94ThROHz+78v/E079IA5z1i7i pyp9J3OPZPIWllICNUdyxsjtHBKdG891ESu0Y5hr2HnB6+85Rii9H5E1fQ8yPvdvj/4J Z0kg== X-Forwarded-Encrypted: i=1; AJvYcCVItSoyJ90X+p5PvDHWCG0UADJIo7+ZWtNbWf7ZnZKJiFPpCpZXrrfQjPkjn4WZgyZvWSuWOVCRuqTwrw==@postgresql.org X-Gm-Message-State: AOJu0YxO209pYZlYIQiHahHiQ2A5/FUTHiBszfCPTInqoashAqoZQdc3 ZRYhLTtR8Au2mFr5I6p6pKiVo3SA72gEZel1bh04+05VlwYREYfYKih9qxJlPReaFPk= X-Gm-Gg: ASbGncsVqf9AaZD1MsA9EHYCy+jZDSJicFuZl/rFnnkmTc+Z/3A2DFtrejOntTrC6aH 9/0luigmwFtgjulASEP3umlQGTOC0sXlX2sgzrjqwjq5oaos7NcXx+TOcXJFZ0VBAYSLeWQoLjy lF4D1Jszn3aHahx2PzFmT0K4MfYWCsprnx8dlE0eJvnAhGM8ZPtByiMy0qK+uZdrNvKIYV7bBti j+w9s2xh7NejEcb62twaCB5K4rv4swl0EuYFr+npmXqkm9wTaOCQLoC8eRWiZiz7BEDMA9NR0Le j9J9Dfs2Li+5C1jTWz4rMl/lEkyYZ485+DRtrTArw3GGH90iKW+PW2v+KM92t8J/k75++oh5YUG aPcmLkATrGiL/KwFuxiyXVtX2dmxqFfmAUclZQVJixS7hTcBj/uo/T9uCwCMKv48= X-Google-Smtp-Source: AGHT+IHWdoJ/XeIlZf2nQ2rZuHzkg3gLX3mJoRcO7Cg22PBNs5WclyD3Vt94fatEq9uVUUvknmfsdA== X-Received: by 2002:a05:6000:250f:b0:3e7:64c8:2dba with SMTP id ffacd0b85a97d-3e765a051e9mr4431176f8f.38.1757710748422; Fri, 12 Sep 2025 13:59:08 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:255:30a:2403:9037:2d08:c2c]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3e7607d7c0dsm7904110f8f.47.2025.09.12.13.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Sep 2025 13:59:07 -0700 (PDT) Message-ID: <2abf54a409ea1a3aac778040cf2035d2b9230e22.camel@cybertec.at> Subject: Re: pg_stats.correlation rule of thumb for re-clustering a table? From: Laurenz Albe To: Ron Johnson , pgsql-admin Date: Fri, 12 Sep 2025 22:59:07 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 2025-09-12 at 10:46 -0400, Ron Johnson wrote: > Purely OLTP tables (that are only accessed randomly) can of course live w= ith 0% correlation, > but lots of tables are mixed-use, and so benefit from physical ordering o= n=C2=A0a carefully=C2=A0chosen field.. >=20 > SELECT abs(correlation)::numeric(3,2) as correlation > FROM pg_stats=20 > WHERE schemaname =3D 'foo' AND tablename =3D 'bar' > =C2=A0 AND attname =3D 'blarge'; > =C2=A0correlation > ------------- > =C2=A0 =C2=A0 =C2=A0 =C2=A0 0.84 > (1 row) >=20 > Obviously 84% is no need to worry, but what about 60% or 40%? Currently, = I use 60%, but would like to do better. Either the difference is gradual, so that it there is no real cut-off point= , or there is a sudden plan change at some point that depends on the query th= e data and the parameter settings. I don't think it is possible to give reli= able numbers that cover all cases. I suggest that you run a series of benchmarks with a copy of the table with different correlation values and come up with numbers that are meaningful for your individual case. Yours, Laurenz Albe