Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eHyWF-0000oH-LS for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Nov 2017 20:54:47 +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 1eHyWD-0005T9-FS for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Nov 2017 20:54:45 +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 1eHyWD-0005Sz-5S for pgsql-hackers@lists.postgresql.org; Thu, 23 Nov 2017 20:54:45 +0000 Received: from mail-wm0-x22e.google.com ([2a00:1450:400c:c09::22e]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eHyW5-0005mn-32 for pgsql-hackers@postgresql.org; Thu, 23 Nov 2017 20:54:44 +0000 Received: by mail-wm0-x22e.google.com with SMTP id y80so18885036wmd.0 for ; Thu, 23 Nov 2017 12:54:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-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=uFl32MnuA40bn3FWO5ja3fNHDxUo7uEw9eNrghap/ZU=; b=diENjZWl4aM8RxPT7Nxmj/wbrwYhGhyXU96jV/WlGAwIFQJMl7okUC7pbqLHa06bvR 34vmF5W3gCVf9XnMw2H85yLZAihFLY1Fn/fJWD12LulK1xFWaHkAB2cDb5ThvdELtRkN PYhFuZd/najUTOSY1eCKjE3CGFtp1IaeffYCxilCD0/GVJtq9wYFzFRJQKHEoxDvbS85 TDwzgeHu3EM9scn5Er+Fuk+0jitwKZ8X0N50p87K9qGOS8xRoO/+q+jFdGVHnplmJ6Wp 7UtxeLv+kTK8jUJTR+9YychwQlG6TQCgfnCFQqnj3Kjf+HsCObU+oob9+tprxX8fqWK6 6hLA== 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=uFl32MnuA40bn3FWO5ja3fNHDxUo7uEw9eNrghap/ZU=; b=BsAODcNzrNfaNXD6ZN8CSl5VSrHHD0ep0cY5L78gwCiq6lBZ1CjdimFLofSD6rjtMD l5iTHd55JJHNr76IeGSoVKZYJkp8p08Z/+KFNMet5dPsfGgCmmQOYNd17ApNoVXEx4oD DXSf8WaJJCgcFABt8HtHIrlhS8mpqGYMTgpXO3Icq+1rJZnoqKcbEfct0Vxn6Jy96oBr zrXLohdAgMvKCoQAL5Sy9SwXzEt2szRL5fzOHfo2wKlcLpVrVzP+PW0rd18x12mSAIJO 9qkGXSpMHcKk2aZp6BHqna9YnZUXBDjllTbjfnbXovzokN2e3xcntgTkMIRjQ1H7uKfL iejQ== X-Gm-Message-State: AJaThX4XZbwcKtxjoG4Jb/xOEl+VHizdJtkVao6LClrPLvGnQBInS1y1 Sa9x4EmiP3UsX6l0P0WouEM2oA== X-Google-Smtp-Source: AGs4zMaUrTPTc6KzRArjZ3vzWlfjfS7W4bU6zaCaZpkb8wcJ8n9PAtbvq5xcGCoFxMj8EBZXkTJ1MA== X-Received: by 10.28.221.138 with SMTP id u132mr7388053wmg.113.1511470475923; Thu, 23 Nov 2017 12:54:35 -0800 (PST) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id x13sm875073wre.65.2017.11.23.12.54.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 12:54:35 -0800 (PST) Subject: Re: [HACKERS] Custom compression methods To: Ildus Kurbangaliev Cc: pgsql-hackers@postgresql.org, Ildar Musin 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> <20171123123849.5a686d7b@wp.localdomain> From: Tomas Vondra Message-ID: <57daf28d-ed76-c364-a9ca-65d0ff71a36f@2ndquadrant.com> Date: Thu, 23 Nov 2017 21:54:32 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20171123123849.5a686d7b@wp.localdomain> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 11/23/2017 10:38 AM, Ildus Kurbangaliev wrote: > On Tue, 21 Nov 2017 18:47:49 +0100 > Tomas Vondra wrote: > >>> >> >> 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. > > Should be fixed in the attached patch. I've changed your extension a > little bit according changes in the new patch (also in attachments). > Hmm, this seems to have fixed it, but only in one direction. Consider this: create table t_pglz (v text); create table t_lz4 (v text compressed lz4); insert into t_pglz select repeat(md5(i::text),300) from generate_series(1,100000) s(i); insert into t_lz4 select repeat(md5(i::text),300) from generate_series(1,100000) s(i); \d+ Schema | Name | Type | Owner | Size | Description --------+--------+-------+-------+-------+------------- public | t_lz4 | table | user | 12 MB | public | t_pglz | table | user | 18 MB | (2 rows) truncate t_pglz; insert into t_pglz select * from t_lz4; \d+ Schema | Name | Type | Owner | Size | Description --------+--------+-------+-------+-------+------------- public | t_lz4 | table | user | 12 MB | public | t_pglz | table | user | 18 MB | (2 rows) which is fine. But in the other direction, this happens truncate t_lz4; insert into t_lz4 select * from t_pglz; \d+ List of relations Schema | Name | Type | Owner | Size | Description --------+--------+-------+-------+-------+------------- public | t_lz4 | table | user | 18 MB | public | t_pglz | table | user | 18 MB | (2 rows) which means the data is still pglz-compressed. That's rather strange, I guess, and it should compress the data using the compression method set for the target table instead. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services