pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix BRIN minmax-multi distance for interval type 10+ messages / 1 participants [nested] [flat]
* pgsql: Fix BRIN minmax-multi distance for interval type @ 2021-04-04 17:21 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 10+ messages in thread From: Tomas Vondra @ 2021-04-04 17:21 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix BRIN minmax-multi distance for interval type The distance calculation for interval type was treating months as having 31 days, which is inconsistent with the interval comparator (using 30 days). Due to this it was possible to get negative distance (b-a) when (a<b), trigerring an assert. Fixed by adopting the same logic as interval_cmp_value. Reported-by: Jaime Casanova Discussion: https://postgr.es/m/CAJKUy5jKH0Xhneau2mNftNPtTy-BVgQfXc8zQkEvRvBHfeUThQ%40mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/2b10e0e3c2ca14d732521479123e5d5e2094e143 Modified Files -------------- src/backend/access/brin/brin_minmax_multi.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 10+ messages in thread
* pgsql: Fix BRIN minmax-multi distance for timetz type @ 2021-04-04 17:23 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 10+ messages in thread From: Tomas Vondra @ 2021-04-04 17:23 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix BRIN minmax-multi distance for timetz type The distance calculation ignored the time zone, so the result of (b-a) might have ended negative even if (b > a). Fixed by considering the time zone difference. Reported-by: Jaime Casanova Discussion: https://postgr.es/m/CAJKUy5jLZFLCxyxfT%3DMfK5mtPfSzHA1rVLowR-j4RRsFVvKm7A%40mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/7262f2421a1e099a631356f7b80ad198e34e2a8a Modified Files -------------- src/backend/access/brin/brin_minmax_multi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) ^ permalink raw reply [nested|flat] 10+ messages in thread
* pgsql: Fix BRIN minmax-multi distance for inet type @ 2021-04-04 17:25 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 10+ messages in thread From: Tomas Vondra @ 2021-04-04 17:25 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix BRIN minmax-multi distance for inet type The distance calculation ignored the mask, unlike the inet comparator, which resulted in negative distance in some cases. Fixed by applying the mask in brin_minmax_multi_distance_inet. I've considered simply calling inetmi() to calculate the delta, but that does not consider mask either. Reviewed-by: Zhihong Yu Discussion: https://postgr.es/m/1a0a7b9d-9bda-e3a2-7fa4-88f15042a051%40enterprisedb.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/e1fbe1181c86247eaf8b4b142b81361ce4efcc66 Modified Files -------------- src/backend/access/brin/brin_minmax_multi.c | 59 +++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 8 deletions(-) ^ permalink raw reply [nested|flat] 10+ messages in thread
* pgsql: Fix BRIN minmax-multi distance for tid values @ 2026-11-02 21:07 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 10+ messages in thread From: Tomas Vondra @ 2026-11-02 21:07 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix BRIN minmax-multi distance for tid values The distance function for tid values maps item pointers to float8 as (block * MaxHeapTuplesPerPage + offset) but the multiplication was done in uint32 arithmetic, so for high block values (above 14759338, ~112GB) the result wrapped around. The distance would then be very inaccurate (possibly negative), resulting in a less efficient index. Fix by doing the arithmetics in double. It's also possible the (user-supplied) item pointers have offsets greater than MaxHeapTuplesPerPage, confusing the mapping to double value. This commit does not try to address that, it's not clear what would be a better mapping. Author: Tomas Vondra <tomas@vondra.me> Backpatch-through: 14 Discussion: https://postgr.es/m/CALdSSPgBvXz-VSF0p-5k%3D_uFfN38cWrERmm_AC4K67N6MWQhmg%40mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/252432c4cf1425d065cf12eb8aa9d59209233513 Modified Files -------------- src/backend/access/brin/brin_minmax_multi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 10+ messages in thread
* pgsql: Fix BRIN minmax-multi distance for tid values @ 2026-11-02 21:08 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 10+ messages in thread From: Tomas Vondra @ 2026-11-02 21:08 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix BRIN minmax-multi distance for tid values The distance function for tid values maps item pointers to float8 as (block * MaxHeapTuplesPerPage + offset) but the multiplication was done in uint32 arithmetic, so for high block values (above 14759338, ~112GB) the result wrapped around. The distance would then be very inaccurate (possibly negative), resulting in a less efficient index. Fix by doing the arithmetics in double. It's also possible the (user-supplied) item pointers have offsets greater than MaxHeapTuplesPerPage, confusing the mapping to double value. This commit does not try to address that, it's not clear what would be a better mapping. Author: Tomas Vondra <tomas@vondra.me> Backpatch-through: 14 Discussion: https://postgr.es/m/CALdSSPgBvXz-VSF0p-5k%3D_uFfN38cWrERmm_AC4K67N6MWQhmg%40mail.gmail.com Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/9a1d7f3a60964237c066c171cddfb056b43b203b Modified Files -------------- src/backend/access/brin/brin_minmax_multi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 10+ messages in thread
* pgsql: Fix BRIN minmax-multi distance for tid values @ 2026-11-02 21:08 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 10+ messages in thread From: Tomas Vondra @ 2026-11-02 21:08 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix BRIN minmax-multi distance for tid values The distance function for tid values maps item pointers to float8 as (block * MaxHeapTuplesPerPage + offset) but the multiplication was done in uint32 arithmetic, so for high block values (above 14759338, ~112GB) the result wrapped around. The distance would then be very inaccurate (possibly negative), resulting in a less efficient index. Fix by doing the arithmetics in double. It's also possible the (user-supplied) item pointers have offsets greater than MaxHeapTuplesPerPage, confusing the mapping to double value. This commit does not try to address that, it's not clear what would be a better mapping. Author: Tomas Vondra <tomas@vondra.me> Backpatch-through: 14 Discussion: https://postgr.es/m/CALdSSPgBvXz-VSF0p-5k%3D_uFfN38cWrERmm_AC4K67N6MWQhmg%40mail.gmail.com Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/1be7010d1bae749ddeea46eb8398f14689b9a2c8 Modified Files -------------- src/backend/access/brin/brin_minmax_multi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 10+ messages in thread
* pgsql: Fix BRIN minmax-multi distance for tid values @ 2026-11-02 21:08 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 10+ messages in thread From: Tomas Vondra @ 2026-11-02 21:08 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix BRIN minmax-multi distance for tid values The distance function for tid values maps item pointers to float8 as (block * MaxHeapTuplesPerPage + offset) but the multiplication was done in uint32 arithmetic, so for high block values (above 14759338, ~112GB) the result wrapped around. The distance would then be very inaccurate (possibly negative), resulting in a less efficient index. Fix by doing the arithmetics in double. It's also possible the (user-supplied) item pointers have offsets greater than MaxHeapTuplesPerPage, confusing the mapping to double value. This commit does not try to address that, it's not clear what would be a better mapping. Author: Tomas Vondra <tomas@vondra.me> Backpatch-through: 14 Discussion: https://postgr.es/m/CALdSSPgBvXz-VSF0p-5k%3D_uFfN38cWrERmm_AC4K67N6MWQhmg%40mail.gmail.com Branch ------ REL_17_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/c83ddfcfe9817684f5e2347137b303c6c3763c57 Modified Files -------------- src/backend/access/brin/brin_minmax_multi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 10+ messages in thread
* pgsql: Fix BRIN minmax-multi distance for tid values @ 2026-11-02 21:08 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 10+ messages in thread From: Tomas Vondra @ 2026-11-02 21:08 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix BRIN minmax-multi distance for tid values The distance function for tid values maps item pointers to float8 as (block * MaxHeapTuplesPerPage + offset) but the multiplication was done in uint32 arithmetic, so for high block values (above 14759338, ~112GB) the result wrapped around. The distance would then be very inaccurate (possibly negative), resulting in a less efficient index. Fix by doing the arithmetics in double. It's also possible the (user-supplied) item pointers have offsets greater than MaxHeapTuplesPerPage, confusing the mapping to double value. This commit does not try to address that, it's not clear what would be a better mapping. Author: Tomas Vondra <tomas@vondra.me> Backpatch-through: 14 Discussion: https://postgr.es/m/CALdSSPgBvXz-VSF0p-5k%3D_uFfN38cWrERmm_AC4K67N6MWQhmg%40mail.gmail.com Branch ------ REL_16_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/7e0d03a91618ff9f7524d238a9dce1085f8fd6e3 Modified Files -------------- src/backend/access/brin/brin_minmax_multi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 10+ messages in thread
* pgsql: Fix BRIN minmax-multi distance for tid values @ 2026-11-02 21:08 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 10+ messages in thread From: Tomas Vondra @ 2026-11-02 21:08 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix BRIN minmax-multi distance for tid values The distance function for tid values maps item pointers to float8 as (block * MaxHeapTuplesPerPage + offset) but the multiplication was done in uint32 arithmetic, so for high block values (above 14759338, ~112GB) the result wrapped around. The distance would then be very inaccurate (possibly negative), resulting in a less efficient index. Fix by doing the arithmetics in double. It's also possible the (user-supplied) item pointers have offsets greater than MaxHeapTuplesPerPage, confusing the mapping to double value. This commit does not try to address that, it's not clear what would be a better mapping. Author: Tomas Vondra <tomas@vondra.me> Backpatch-through: 14 Discussion: https://postgr.es/m/CALdSSPgBvXz-VSF0p-5k%3D_uFfN38cWrERmm_AC4K67N6MWQhmg%40mail.gmail.com Branch ------ REL_15_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/6a770f537fcebc0fb7276c676223abdca96dd5e1 Modified Files -------------- src/backend/access/brin/brin_minmax_multi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 10+ messages in thread
* pgsql: Fix BRIN minmax-multi distance for tid values @ 2026-11-02 21:08 Tomas Vondra <tomas.vondra@postgresql.org> 0 siblings, 0 replies; 10+ messages in thread From: Tomas Vondra @ 2026-11-02 21:08 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix BRIN minmax-multi distance for tid values The distance function for tid values maps item pointers to float8 as (block * MaxHeapTuplesPerPage + offset) but the multiplication was done in uint32 arithmetic, so for high block values (above 14759338, ~112GB) the result wrapped around. The distance would then be very inaccurate (possibly negative), resulting in a less efficient index. Fix by doing the arithmetics in double. It's also possible the (user-supplied) item pointers have offsets greater than MaxHeapTuplesPerPage, confusing the mapping to double value. This commit does not try to address that, it's not clear what would be a better mapping. Author: Tomas Vondra <tomas@vondra.me> Backpatch-through: 14 Discussion: https://postgr.es/m/CALdSSPgBvXz-VSF0p-5k%3D_uFfN38cWrERmm_AC4K67N6MWQhmg%40mail.gmail.com Branch ------ REL_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/c48577385d15245691dbbff3bf25f1a1b58fe70e Modified Files -------------- src/backend/access/brin/brin_minmax_multi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 10+ messages in thread
end of thread, other threads:[~2026-11-02 21:08 UTC | newest] Thread overview: 10+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-04-04 17:21 pgsql: Fix BRIN minmax-multi distance for interval type Tomas Vondra <tomas.vondra@postgresql.org> 2021-04-04 17:23 pgsql: Fix BRIN minmax-multi distance for timetz type Tomas Vondra <tomas.vondra@postgresql.org> 2021-04-04 17:25 pgsql: Fix BRIN minmax-multi distance for inet type Tomas Vondra <tomas.vondra@postgresql.org> 2026-11-02 21:07 pgsql: Fix BRIN minmax-multi distance for tid values Tomas Vondra <tomas.vondra@postgresql.org> 2026-11-02 21:08 pgsql: Fix BRIN minmax-multi distance for tid values Tomas Vondra <tomas.vondra@postgresql.org> 2026-11-02 21:08 pgsql: Fix BRIN minmax-multi distance for tid values Tomas Vondra <tomas.vondra@postgresql.org> 2026-11-02 21:08 pgsql: Fix BRIN minmax-multi distance for tid values Tomas Vondra <tomas.vondra@postgresql.org> 2026-11-02 21:08 pgsql: Fix BRIN minmax-multi distance for tid values Tomas Vondra <tomas.vondra@postgresql.org> 2026-11-02 21:08 pgsql: Fix BRIN minmax-multi distance for tid values Tomas Vondra <tomas.vondra@postgresql.org> 2026-11-02 21:08 pgsql: Fix BRIN minmax-multi distance for tid values 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