pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Why can NUMERIC columns not use deduplication?
2+ messages / 2 participants
[nested] [flat]

* Why can NUMERIC columns not use deduplication?
@ 2022-01-14 13:57  PG Doc comments form <noreply@postgresql.org>
  0 siblings, 1 reply; 2+ messages in thread

From: PG Doc comments form @ 2022-01-14 13:57 UTC (permalink / raw)
  To: pgsql-docs@lists.postgresql.org; +Cc: chris+postgresql@qwirx.com

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/btree-implementation.html
Description:

"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?

Even in the special case of a NUMERIC column with no precision or scale
(8.1.2), for example if a table has an index on a NUMERIC column, and some
rows have the value 8 in that column, and some have the value 8.0 (I think
these are different values/datums in this special case), I would not expect
all those index entries to be deduplicated into a single list, but I would
expect them to be deduplicated into two lists (one for the value 8, and one
for the value 8.0). Then again I am not familiar with the actual
implementation.


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Why can NUMERIC columns not use deduplication?
@ 2022-01-14 15:14  Tom Lane <tgl@sss.pgh.pa.us>
  parent: PG Doc comments form <noreply@postgresql.org>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2022-01-14 15:14 UTC (permalink / raw)
  To: chris+postgresql@qwirx.com; +Cc: pgsql-docs@lists.postgresql.org

PG Doc comments form <noreply@postgresql.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





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2022-01-14 15:14 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-01-14 13:57 Why can NUMERIC columns not use deduplication? PG Doc comments form <noreply@postgresql.org>
2022-01-14 15:14 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox