Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eP5zY-0006uM-8a for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Dec 2017 12:18:29 +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 1eP5zV-0000Ru-Qw for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Dec 2017 12:18:25 +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 1eP5zV-0000Rk-G6 for pgsql-hackers@lists.postgresql.org; Wed, 13 Dec 2017 12:18:25 +0000 Received: from mail.postgrespro.ru ([93.174.131.138]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eP5zS-00069o-Gg for pgsql-hackers@postgresql.org; Wed, 13 Dec 2017 12:18:24 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 6AC3121C1B04; Wed, 13 Dec 2017 15:18:20 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru Received: from localhost.localdomain (unknown [31.173.148.242]) (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 E7E0C21C0695; Wed, 13 Dec 2017 15:18:19 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1513167500; bh=uy6xCMDb8yTcf39/QiNt/bZcq1sBS8gHd8HbyjQhGdg=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=h6ojhT4AxGmZW2wHKn9poyi4FdqhOn1xh5Mlchwgz5SY4E3ChaaiX7vwTrES4y7e4 rDqqEatH3uUO4uVPLjMEHK2tbVDWO6PO1PX7wHstn8RazQzHNmE9kV6gWZHSfCL2RH EIx1dbdCPn2Q/iZDnIogAKPId8c/OWO1psPb6884= Date: Wed, 13 Dec 2017 15:18:18 +0300 From: Ildus Kurbangaliev To: Robert Haas Cc: Alexander Korotkov , Tomas Vondra , Alvaro Herrera , =?UTF-8?B?0JXQstCz0LXQvdC40Lkg0KjQuNGI0LrQuNC9?= , Andres Freund , Oleg Bartunov , Craig Ringer , Peter Eisentraut , PostgreSQL Hackers , Chapman Flack Subject: Re: [HACKERS] Custom compression methods Message-ID: <20171213151818.75a20259@postgrespro.ru> In-Reply-To: References: <20171201194859.le5hvnnrjzhxhm2t@alvherre.pgsql> <20171206180716.75ba9ba9@postgrespro.ru> <20171211155555.05ddd2fc@postgrespro.ru> 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=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, 12 Dec 2017 15:52:01 -0500 Robert Haas wrote: >=20 > Yes. I wonder if \d or \d+ can show it somehow. >=20 Yes, in current version of the patch, \d+ shows current compression. It can be extended to show a list of current compression methods. Since we agreed on ALTER syntax, i want to clear things about CREATE. Should it be CREATE ACCESS METHOD .. TYPE =D0=A1OMPRESSION or CREATE COMPRESSION METHOD? I like the access method approach, and it simplifies the code, but I'm just not sure a compression is an access method or not. Current implementation ---------------------- To avoid extra patches I also want to clear things about current implementation. Right now there are two tables, "pg_compression" and "pg_compression_opt". When compression method is linked to a column it creates a record in pg_compression_opt. This record's Oid is stored in the varlena. These Oids kept in first column so I can move them in pg_upgrade but in all other aspects they behave like usual Oids. Also it's easy to restore them. Compression options linked to a specific column. When tuple is moved between relations it will be decompressed. Also in current implementation SET COMPRESSION contains WITH syntax which is used to provide extra options to compression method. What could be changed --------------------- As Alvaro mentioned COMPRESSION METHOD is practically an access method, so it could be created as CREATE ACCESS METHOD .. TYPE COMPRESSION. This approach simplifies the patch and "pg_compression" table could be removed. So compression method is created with something like: CREATE ACCESS METHOD .. TYPE COMPRESSION HANDLER awesome_compression_handler; Syntax of SET COMPRESSION changes to SET COMPRESSION .. PRESERVE which is useful to control rewrites and for pg_upgrade to make dependencies between moved compression options and compression methods from pg_am table. Default compression is always pglz and if users want to change they run: ALTER COLUMN SET COMPRESSION awesome PRESERVE pglz; Without PRESERVE it will rewrite the whole relation using new compression. Also the rewrite removes all unlisted compression options so their compresssion methods could be safely dropped. "pg_compression_opt" table could be renamed to "pg_compression", and compression options will be stored there. I'd like to keep extra compression options, for example pglz can be configured with them. Syntax would be slightly changed: SET COMPRESSION pglz WITH (min_comp_rate=3D25) PRESERVE awesome; Setting the same compression method with different options will create new compression options record for future tuples but will not rewrite table. --=20 ---- Regards, Ildus Kurbangaliev