pg_statistic MCVs use float4 but extended stats use float8

Started by Justin Pryzbyalmost 4 years ago2 messageshackers
Jump to latest
#1Justin Pryzby
pryzby@telsasoft.com

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

Attachments:

t47445_1
0001-WIP-mcv.c-use-float4-for-mcv-frequencies.patchtext/x-diff; charset=us-asciiDownload+22-23
#2Tomas Vondra
tomas.vondra@enterprisedb.com
In reply to: Justin Pryzby (#1)
Re: pg_statistic MCVs use float4 but extended stats use float8

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[] | v

I'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