Re: Why can NUMERIC columns not use deduplication?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: chris+postgresql(at)qwirx(dot)com
Cc: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: Why can NUMERIC columns not use deduplication?
Date: 2022-01-14 15:14:41
Message-ID: 3379157.1642173281@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

PG Doc comments form <noreply(at)postgresql(dot)org> writes:
> "64.4.3. Deduplication" says:
> "numeric cannot use deduplication. Numeric display scale must be preserved
> among equal datums."

> However I don't understand this. An equal datum is an equal datum regardless
> of display scale, isn't it?

No. For example:

regression=# select 1.0, 1.00;
?column? | ?column?
----------+----------
1.0 | 1.00
(1 row)

regression=# select 1.0 = 1.00;
?column?
----------
t
(1 row)

These values are "equal" per the datatype's equality operator,
but there are some operations (not only output) that can distinguish
them, so the index can't lump them together.

There are similar issues in some other datatypes, for example
zero and minus zero in the float types.

regards, tom lane

In response to

Browse pgsql-docs by date

  From Date Subject
Next Message PG Doc comments form 2022-01-15 23:01:58 CREATE INDEX USING documentation
Previous Message PG Doc comments form 2022-01-14 13:57:59 Why can NUMERIC columns not use deduplication?