Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lNY1A-0006M9-On for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Mar 2021 09:35:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lNY19-00035s-Ao for pgsql-hackers@arkaria.postgresql.org; Sat, 20 Mar 2021 09:35:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lNY19-00035l-3P for pgsql-hackers@lists.postgresql.org; Sat, 20 Mar 2021 09:35:35 +0000 Received: from mail-ed1-x535.google.com ([2a00:1450:4864:20::535]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lNY16-0005wm-F4 for pgsql-hackers@lists.postgresql.org; Sat, 20 Mar 2021 09:35:34 +0000 Received: by mail-ed1-x535.google.com with SMTP id j3so13539597edp.11 for ; Sat, 20 Mar 2021 02:35:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Ardm5MsvXIZo+i0e2dgUqCyGiZIb58RpYATUHzXEyqQ=; b=lLUKdHuM3YzNmCIRXIQy9+ZdhUc1tnDFUUtprJWBoF7c9MwgajZaRHeC/+G1Tnt3Xc ldvegvd6rlTw0eIH+WroynsuAe53TtU+lREMcM0+MNs5zSA8pxWUo3ubgJD8PYS1O5D8 dLNvMQTSrgdDWQFoIKB0kCmcGX17YGpdRXKY0z6ivuqCKXpM6Y9dK1S51yLu18RfTjRj JyKRAkAqQ8C62v6FNw8oS1fn8SrMT9zw4i90MN2fJTdv6RUcnVVc8Mjz3a06PQZJvHJP qzzJ9M4uy/9p0peQSa0+Cey6ogey7kWC0Jc0/KDASYiKhJYrQ2hAlkOv11/xecLS4K7P 8JtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Ardm5MsvXIZo+i0e2dgUqCyGiZIb58RpYATUHzXEyqQ=; b=XDEAy81pVJgRD7eZyhB7phEQREuiYu/g0WZ5ljcCgcyheAppbwQZZXo5gExRPvCCFE ZAeCbAoF6xCIGDYiWUul1U2h11aNd16T/GxlD6GnzxslM/Dd1B7r56KiiMNqcTAOtdDH bwj/CdA8P2ZCppJyom4GuMjLt3WFyEFHd5Ik9qdt17BMjP3BZRwhtLJPxk6VH6qcLUBH fn5kQ+jfqxHHKkICt6pSlkal7OgYej+/hWkDhavpRATmPP43fNuNHUq1WKjocIN1qTY4 HLqNZDp5Wf2ZNGOR+m/aNbxGaGMgWeq/mLPr7VhsTgtfw1y/9eP+3bv1u4cDonOSX6Ts JT3g== X-Gm-Message-State: AOAM532XT7Pzg7PIMH2EEoiqKWCLEJ6k2z0ACavA6BJ/gC/dXcjaxpZy 8dl4Wo+7hHcHmpQ4v8su7UdDByaBaAtmqnz5FEk8Ez1P7FcM4P9gIIMMSdFTYHEhhT5g+1bVTZ+ 6LZGdpHgMcaf/LLsFnpNjuATy0F5DDbu3WERjtGmOi0+2L9ST3+xmjCd7oQAlHqbJqyL2VCfTPC dbMuHPAuQBhGi0u/tnA+Wj4sw/ZqMe6vKUuydDahxpkZ4F7z4WWn9gHAAauNvCX+2cvuj3IhLa1 8RTTY1y9EqbyXAG12wOQrnOCzIl4IQ/AW8MpfAJkjvPGFgCOSSQSg== X-Google-Smtp-Source: ABdhPJwEjl7x37ExS2xfvENnJ1Md59CUX4IIc5kkEDsaa4iyIvJbIZqUG17jJ0b56nB/glaRDeUrGA== X-Received: by 2002:a05:6402:1649:: with SMTP id s9mr14581117edx.177.1616232930495; Sat, 20 Mar 2021 02:35:30 -0700 (PDT) Received: from [10.137.0.20] (ip-86-49-253-127.net.upcbroadband.cz. [86.49.253.127]) by smtp.gmail.com with ESMTPSA id u1sm5561173edv.90.2021.03.20.02.35.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 20 Mar 2021 02:35:29 -0700 (PDT) Subject: Re: [HACKERS] Custom compression methods To: Robert Haas , Dilip Kumar Cc: Andres Freund , Justin Pryzby , Tomas Vondra , Alexander Korotkov , David Steele , Ildus Kurbangaliev , Dmitry Dolgov <9erthalion6@gmail.com>, PostgreSQL Hackers References: <20210311032057.GZ2021@telsasoft.com> <20210312103650.GR8796@telsasoft.com> <20210315225835.2toe2ceanp7gi6fw@alap3.anarazel.de> From: Tomas Vondra Message-ID: Date: Sat, 20 Mar 2021 10:35:26 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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