Re: Is there value in having optimizer stats for joins/foreignkeys?
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tomas Vondra <tomas@vondra.me>
Cc: Corey Huinker <corey.huinker@gmail.com>,
pgsql-hackers@lists.postgresql.org, hs@cybertec.at,
Jeff Davis <pgsql@j-davis.com>
Date: 2025-12-01T22:11:55Z
Lists: pgsql-hackers
Tomas Vondra <tomas@vondra.me> writes: > On 12/1/25 21:10, Corey Huinker wrote: >> Threads like [1] and [2] have gotten me thinking that there may be some >> value in storing statistics about joins. > Do I understand correctly you propose to collect such stats for every > foreign key? I recall something like that was proposed in the past, and > the argument against was that for many joins it'd be a waste because the > estimates are good enough. And for OLTP systems that's probably true. Yeah, I think that automated choices about this are unlikely to work well. We chose the syntax for CREATE STATISTICS with an eye to allowing users to declaratively tell us to collect stats about specific joins, and I still think that's a more promising approach. But nobody's yet worked out any details. regards, tom lane