pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Fix calculation in brin_minmax_multi_distance_date
4+ messages / 1 participants
[nested] [flat]

* pgsql: Fix calculation in brin_minmax_multi_distance_date
@ 2023-10-27 16:57  Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Tomas Vondra @ 2023-10-27 16:57 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix calculation in brin_minmax_multi_distance_date

When calculating the distance between date values, make sure to subtract
them in the right order, i.e. (larger - smaller).

The distance is used to determine which values to merge, and is expected
to be a positive value. The code unfortunately did the subtraction in
the opposite order, i.e. (smaller - larger), thus producing negative
values and merging values the most distant values first.

The resulting index is correct (i.e. produces correct results), but may
be significantly less efficient. This affects all minmax-multi indexes
on date columns.

Backpatch to 14, where minmax-multi indexes were introduced.

Reported-by: Ashutosh Bapat
Reviewed-by: Ashutosh Bapat, Dean Rasheed
Backpatch-through: 14
Discussion: https://postgr.es/m/eef0ea8c-4aaa-8d0d-027f-58b1f35dd170@enterprisedb.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/394d51731495794655f95b5580adb757d7a9bbe2

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c |  7 ++++++-
src/test/regress/expected/brin_multi.out    | 20 ++++++++++++++++++++
src/test/regress/sql/brin_multi.sql         | 18 ++++++++++++++++++
3 files changed, 44 insertions(+), 1 deletion(-)



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

* pgsql: Fix calculation in brin_minmax_multi_distance_date
@ 2023-10-27 16:58  Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Tomas Vondra @ 2023-10-27 16:58 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix calculation in brin_minmax_multi_distance_date

When calculating the distance between date values, make sure to subtract
them in the right order, i.e. (larger - smaller).

The distance is used to determine which values to merge, and is expected
to be a positive value. The code unfortunately did the subtraction in
the opposite order, i.e. (smaller - larger), thus producing negative
values and merging values the most distant values first.

The resulting index is correct (i.e. produces correct results), but may
be significantly less efficient. This affects all minmax-multi indexes
on date columns.

Backpatch to 14, where minmax-multi indexes were introduced.

Reported-by: Ashutosh Bapat
Reviewed-by: Ashutosh Bapat, Dean Rasheed
Backpatch-through: 14
Discussion: https://postgr.es/m/eef0ea8c-4aaa-8d0d-027f-58b1f35dd170@enterprisedb.com

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/e7965226d5518796cb2c1a48635ae92b5fe4e6ef

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c |  7 ++++++-
src/test/regress/expected/brin_multi.out    | 20 ++++++++++++++++++++
src/test/regress/sql/brin_multi.sql         | 18 ++++++++++++++++++
3 files changed, 44 insertions(+), 1 deletion(-)



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

* pgsql: Fix calculation in brin_minmax_multi_distance_date
@ 2023-10-27 16:59  Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Tomas Vondra @ 2023-10-27 16:59 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix calculation in brin_minmax_multi_distance_date

When calculating the distance between date values, make sure to subtract
them in the right order, i.e. (larger - smaller).

The distance is used to determine which values to merge, and is expected
to be a positive value. The code unfortunately did the subtraction in
the opposite order, i.e. (smaller - larger), thus producing negative
values and merging values the most distant values first.

The resulting index is correct (i.e. produces correct results), but may
be significantly less efficient. This affects all minmax-multi indexes
on date columns.

Backpatch to 14, where minmax-multi indexes were introduced.

Reported-by: Ashutosh Bapat
Reviewed-by: Ashutosh Bapat, Dean Rasheed
Backpatch-through: 14
Discussion: https://postgr.es/m/eef0ea8c-4aaa-8d0d-027f-58b1f35dd170@enterprisedb.com

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/088233f8db6c22cbff6c29c212ce138236a5bcc1

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c |  7 ++++++-
src/test/regress/expected/brin_multi.out    | 20 ++++++++++++++++++++
src/test/regress/sql/brin_multi.sql         | 18 ++++++++++++++++++
3 files changed, 44 insertions(+), 1 deletion(-)



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

* pgsql: Fix calculation in brin_minmax_multi_distance_date
@ 2023-10-27 16:59  Tomas Vondra <tomas.vondra@postgresql.org>
  0 siblings, 0 replies; 4+ messages in thread

From: Tomas Vondra @ 2023-10-27 16:59 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

Fix calculation in brin_minmax_multi_distance_date

When calculating the distance between date values, make sure to subtract
them in the right order, i.e. (larger - smaller).

The distance is used to determine which values to merge, and is expected
to be a positive value. The code unfortunately did the subtraction in
the opposite order, i.e. (smaller - larger), thus producing negative
values and merging values the most distant values first.

The resulting index is correct (i.e. produces correct results), but may
be significantly less efficient. This affects all minmax-multi indexes
on date columns.

Backpatch to 14, where minmax-multi indexes were introduced.

Reported-by: Ashutosh Bapat
Reviewed-by: Ashutosh Bapat, Dean Rasheed
Backpatch-through: 14
Discussion: https://postgr.es/m/eef0ea8c-4aaa-8d0d-027f-58b1f35dd170@enterprisedb.com

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/d1740e169d950d457907bbfa32f39f79c8504e20

Modified Files
--------------
src/backend/access/brin/brin_minmax_multi.c |  7 ++++++-
src/test/regress/expected/brin_multi.out    | 20 ++++++++++++++++++++
src/test/regress/sql/brin_multi.sql         | 18 ++++++++++++++++++
3 files changed, 44 insertions(+), 1 deletion(-)



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


end of thread, other threads:[~2023-10-27 16:59 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-10-27 16:57 pgsql: Fix calculation in brin_minmax_multi_distance_date Tomas Vondra <tomas.vondra@postgresql.org>
2023-10-27 16:58 pgsql: Fix calculation in brin_minmax_multi_distance_date Tomas Vondra <tomas.vondra@postgresql.org>
2023-10-27 16:59 pgsql: Fix calculation in brin_minmax_multi_distance_date Tomas Vondra <tomas.vondra@postgresql.org>
2023-10-27 16:59 pgsql: Fix calculation in brin_minmax_multi_distance_date Tomas Vondra <tomas.vondra@postgresql.org>

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