pg_statistic MCVs use float4 but extended stats use float8
It seems odd that stats_ext uses double:
postgres=# SELECT attrelid::regclass, attname, atttypid::regtype, relkind FROM pg_attribute a JOIN pg_class c ON c.oid=a.attrelid WHERE attname='most_common_freqs';
attrelid | attname | atttypid | relkind
--------------------+-------------------+--------------------+---------
pg_stats | most_common_freqs | real[] | v
pg_stats_ext | most_common_freqs | double precision[] | v
pg_stats_ext_exprs | most_common_freqs | real[] | v
I'm not sure if that's deliberate ?
This patch changes extended stats to match.
--
Justin
Hi,
On 2/15/23 02:20, Justin Pryzby wrote:
It seems odd that stats_ext uses double:
postgres=# SELECT attrelid::regclass, attname, atttypid::regtype, relkind FROM pg_attribute a JOIN pg_class c ON c.oid=a.attrelid WHERE attname='most_common_freqs';
attrelid | attname | atttypid | relkind
--------------------+-------------------+--------------------+---------
pg_stats | most_common_freqs | real[] | v
pg_stats_ext | most_common_freqs | double precision[] | v
pg_stats_ext_exprs | most_common_freqs | real[] | vI'm not sure if that's deliberate ?
Not really, I'm not sure why I chose float8 and not float4. Likely a
cause of muscle memory on 64-bit systems.
I wonder if there are practical reasons to change this, i.e. if the
float8 can have adverse effects on some systems. Yes, it makes the stats
a little bit larger, but I doubt the difference is significant enough to
make a difference. Perhaps on 32-bit systems it's worse, because float8
is going to be pass-by-ref there ...
regards
--
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company