pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: Robert Haas <robertmhaas@gmail.com>
To: Dilip Kumar <dilipbalaut@gmail.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Justin Pryzby <pryzby@telsasoft.com>
Cc: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: Alexander Korotkov <a.korotkov@postgrespro.ru>
Cc: David Steele <david@pgmasters.net>
Cc: Ildus Kurbangaliev <i.kurbangaliev@gmail.com>
Cc: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: [HACKERS] Custom compression methods
Date: Sat, 20 Mar 2021 10:35:26 +0100
Message-ID: <e0367f27-392c-321a-7411-a58e1a7e4817@enterprisedb.com> (raw)
In-Reply-To: <CA+TgmoZHcy=bU+yTAewwCePQTL2xhzS3mc8AJ=zNJKbqTsSZpg@mail.gmail.com>
References: <CA+TgmoZ9sWS_8OHqvTAhmRX-2PoK4UMFiSU4QgKbhAosT1RTzQ@mail.gmail.com>
	<CAFiTN-sK1TbCpbFRDF+-TaG4G_hw4S4vUKujGepwg_A7On9UNg@mail.gmail.com>
	<20210311032057.GZ2021@telsasoft.com>
	<CAFiTN-tzAzGroskaqm-cCOctHxBpDccXkKsDPBX4RTv9ETpBNw@mail.gmail.com>
	<CAFiTN-snEyq1QG5TgkoQeVyCvJHqw5m5Nq416ZpPcs372Z-4Gw@mail.gmail.com>
	<20210312103650.GR8796@telsasoft.com>
	<CAFiTN-s8SsWs2zCZL3TFxXwi4VE35J=4aKpduKVrTaL+3wnB0A@mail.gmail.com>
	<CA+TgmobRynuR8n18ZyUD4pA-T3tnPk+AME9=bg=jT4s_Uxk22Q@mail.gmail.com>
	<20210315225835.2toe2ceanp7gi6fw@alap3.anarazel.de>
	<CA+Tgmoam+QEwM2=9zfju6Mnc-7499vrtEKX+31w8HwKOOSKvAg@mail.gmail.com>
	<CAFiTN-sBH65e4B5kQB5MT8BQOPajkrKvSdKA-07+ra3f2x4vCA@mail.gmail.com>
	<CAFiTN-tErP5x54pvkZP7yLVJhpNBOZcd5TN_k1BDhjYCA9D0VQ@mail.gmail.com>
	<CA+TgmoYRsapWz2vDSQXFAEL_BAMq1aY37avcq9GAB=SUUvFhaw@mail.gmail.com>
	<CAFiTN-t03PqWCaRW1GoWQa0i2NwYw_p=FDj+Kxu_-rY_viALqw@mail.gmail.com>
	<CA+TgmoZHcy=bU+yTAewwCePQTL2xhzS3mc8AJ=zNJKbqTsSZpg@mail.gmail.com>

Hi,

I think this bit in brin_tuple.c is wrong:

    ...
    Form_pg_attribute att = TupleDescAttr(brdesc->bd_tupdesc,
                                          keyno);
    Datum       cvalue = toast_compress_datum(value,
                                              att->attcompression);

The problem is that this is looking at the index descriptor (i.e. what
types are indexed) instead of the stored type. For BRIN those may be
only loosely related, which is why the code does this a couple lines above:

    /* We must look at the stored type, not at the index descriptor. */
    TypeCacheEntry *atttype
        = brdesc->bd_info[keyno]->oi_typcache[datumno];

For the built-in BRIN opclasses this happens to work, because e.g.
minmax stores two values of the original type. But it may not work for
other out-of-core opclasses, and it certainly doesn't work for the new
BRIN opclasses (bloom and minmax-multi).

Unfortunately, the only thing we have here is the type OID, so I guess
the only option is using GetDefaultToastCompression(). Perhaps we might
include that into BrinOpcInfo too, in the future.


regards

-- 
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company





view thread (430+ messages)  latest in thread

Message-ID: <e0367f27-392c-321a-7411-a58e1a7e4817@enterprisedb.com>
Permalink:  ../e0367f27-392c-321a-7411-a58e1a7e4817@enterprisedb.com/
Also on:    postgresql.org/message-id/e0367f27-392c-321a-7411-a58e1a7e4817@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: tomas.vondra@enterprisedb.com, robertmhaas@gmail.com, dilipbalaut@gmail.com, andres@anarazel.de, pryzby@telsasoft.com, tomas.vondra@2ndquadrant.com, a.korotkov@postgrespro.ru, david@pgmasters.net, i.kurbangaliev@gmail.com, 9erthalion6@gmail.com
  Subject: Re: [HACKERS] Custom compression methods
  In-Reply-To: <e0367f27-392c-321a-7411-a58e1a7e4817@enterprisedb.com>
  References: <CA+TgmoZ9sWS_8OHqvTAhmRX-2PoK4UMFiSU4QgKbhAosT1RTzQ@mail.gmail.com> <20210311032057.GZ2021@telsasoft.com> <CAFiTN-tzAzGroskaqm-cCOctHxBpDccXkKsDPBX4RTv9ETpBNw@mail.gmail.com> <CAFiTN-snEyq1QG5TgkoQeVyCvJHqw5m5Nq416ZpPcs372Z-4Gw@mail.gmail.com> <20210312103650.GR8796@telsasoft.com> <CAFiTN-s8SsWs2zCZL3TFxXwi4VE35J=4aKpduKVrTaL+3wnB0A@mail.gmail.com> <CA+TgmobRynuR8n18ZyUD4pA-T3tnPk+AME9=bg=jT4s_Uxk22Q@mail.gmail.com> <20210315225835.2toe2ceanp7gi6fw@alap3.anarazel.de> <CA+Tgmoam+QEwM2=9zfju6Mnc-7499vrtEKX+31w8HwKOOSKvAg@mail.gmail.com> <CAFiTN-sBH65e4B5kQB5MT8BQOPajkrKvSdKA-07+ra3f2x4vCA@mail.gmail.com> <CAFiTN-tErP5x54pvkZP7yLVJhpNBOZcd5TN_k1BDhjYCA9D0VQ@mail.gmail.com> <CA+TgmoYRsapWz2vDSQXFAEL_BAMq1aY37avcq9GAB=SUUvFhaw@mail.gmail.com> <CAFiTN-t03PqWCaRW1GoWQa0i2NwYw_p=FDj+Kxu_-rY_viALqw@mail.gmail.com> <CA+TgmoZHcy=bU+yTAewwCePQTL2xhzS3mc8AJ=zNJKbqTsSZpg@mail.gmail.com> <e0367f27-392c-321a-7411-a58e1a7e4817@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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