Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHFAG-0000pP-Si for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Nov 2017 20:29:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHFAG-0003wJ-FT for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Nov 2017 20:29:04 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eHFAG-0003w3-73 for pgsql-hackers@lists.postgresql.org; Tue, 21 Nov 2017 20:29:04 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eHFAC-00078N-Tl for pgsql-hackers@postgresql.org; Tue, 21 Nov 2017 20:29:03 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 6CC7321C1CCF; Tue, 21 Nov 2017 23:28:59 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from localhost.localdomain (broadband-46-242-11-76.moscow.rt.ru [46.242.11.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 40C0621C1756; Tue, 21 Nov 2017 23:28:59 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1511296139; bh=iMN5H/HF2kDbX1ROn854HKLd5l2fu2d9n/KjYyDyNGs=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=gN9Y0R6FuwANOKt08dIBmeg7WnCgdAKwOKSVymsZLo6o/LovL7g68FWiIzRuX8IyG i6weA3MOBMuB09fYInZ0Qqr8i/3tld5sNMMsSA8axBbkOfataJ4K4MCIjr7PgXHrsn gRMwdIwB/ndRjOeZcljEUiQyJ38uUN3hQimMUcnM= Date: Tue, 21 Nov 2017 23:28:55 +0300 From: Ildus K To: Tomas Vondra Cc: pgsql-hackers@postgresql.org Subject: Re: [HACKERS] Custom compression methods Message-ID: <20171121232855.349e14a9@postgrespro.ru> In-Reply-To: References: <20170907194236.4cefce96@wp.localdomain> <20170912175505.4afa11fd@wp.localdomain> <20171102152836.60c041e4@wp.localdomain> <20171114162356.52e3d388@wp.localdomain> <62e46a47-08a8-6e06-5e4f-6f52e0a13202@2ndquadrant.com> <20171121174717.69ecd8f4@wp.localdomain> X-Mailer: Claws Mail 3.15.1-dirty (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, 21 Nov 2017 18:47:49 +0100 Tomas Vondra wrote: > > I propose to use either > > CompressionMethodOptions (and CompressionMethodRoutine) > > or > > CompressionOptions (and CompressionRoutine) Sounds good, thanks. > > OK. But then I don't understand why tsvector.c does things like > > VARSIZE(data) - VARHDRSZ_CUSTOM_COMPRESSED - arrsize > VARRAWSIZE_4B_C(data) - arrsize > > instead of > > VARSIZE_ANY_EXHDR(data) - arrsize > VARSIZE_ANY(data) - arrsize > > Seems somewhat confusing. > VARRAWSIZE_4B_C returns original size of data, before compression (from va_rawsize in current postgres, and from va_info in my patch), not size of the already compressed data, so you can't use VARSIZE_ANY here. VARSIZE_ANY_EXHDR in current postgres returns VARSIZE-VARHDRSZ, despite the varlena is compressed or not, so I just kept this behavior for custom compressed varlenas too. If you look into tuptoaster.c you will also see lines like 'VARSIZE(attr) - TOAST_COMPRESS_HDRSZ'. So I think if VARSIZE_ANY_EXHDR will subtract different header sizes then it should subtract them for usual compressed varlenas too. > > > > Hmmm, it still doesn't work for me. See this: > > test=# create extension pg_lz4 ; > CREATE EXTENSION > test=# create table t_lz4 (v text compressed lz4); > CREATE TABLE > test=# create table t_pglz (v text); > CREATE TABLE > test=# insert into t_lz4 select repeat(md5(1::text),300); > INSERT 0 1 > test=# insert into t_pglz select * from t_lz4; > INSERT 0 1 > test=# drop extension pg_lz4 cascade; > NOTICE: drop cascades to 2 other objects > DETAIL: drop cascades to compression options for lz4 > drop cascades to table t_lz4 column v > DROP EXTENSION > test=# \c test > You are now connected to database "test" as user "user". > test=# insert into t_lz4 select repeat(md5(1::text),300);^C > test=# select * from t_pglz ; > ERROR: cache lookup failed for compression options 16419 > > That suggests no recompression happened. I will check that. Is your extension published somewhere?