Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eL9Lm-0002gt-3U for pgsql-hackers@arkaria.postgresql.org; Sat, 02 Dec 2017 15:05:06 +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 1eL9Lk-0005TU-AA for pgsql-hackers@arkaria.postgresql.org; Sat, 02 Dec 2017 15:05: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 1eL9Lj-0005TK-W3 for pgsql-hackers@lists.postgresql.org; Sat, 02 Dec 2017 15:05:04 +0000 Received: from mail-wr0-x243.google.com ([2a00:1450:400c:c0c::243]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eL9Lf-0004Un-Mt for pgsql-hackers@postgresql.org; Sat, 02 Dec 2017 15:05:03 +0000 Received: by mail-wr0-x243.google.com with SMTP id h1so12865481wre.12 for ; Sat, 02 Dec 2017 07:04:59 -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=05/pqJfo5l51n+xRiCrI2bApYlAOmblgOWOHbomxdwY=; b=cZ84Gr4q9kMH+KHwgEsNOMDBElAkLjf0Kg1Oo41xBLXLqFmXXY6xAyx6diiaBe1830 tqgXS/F6u6cmhKqDdvPhVjaPMlBPkMQwqdr5I9IQf0ucPry5exXnBqjj9a04yaK8NTP7 oeuio7LaJqjHhu40BQ2S7AyRCIn3u9cvK+nDJUiShANucf/1ZhVjM0JQYwCIMC5ytMk1 Cls1iAUMcyz1ise6coFQlmSlSa4Ykm86YlLPy1pUdagLG+sOZMrubVBpbFLDxASvskXE jiKft9sGIDTuA5h+djd2hd7G4bYD3vOE10WjCJGXBGflOjhErZqCy7EeAJXCirgW6N/N QhYw== 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=05/pqJfo5l51n+xRiCrI2bApYlAOmblgOWOHbomxdwY=; b=JSE3B0k5Tz4tQyLhqK3nlBGxiE6uwoVq6gyTGd01iWa+BoM1n5Po7LxygQvDLtUtCr 4LztwHk8z75SSSR2gIVoD+p923iT0Yf4DW+hGQ/2r6di+ZS0j8nbHSVTVJsgCzxxsbYc zM9LLH2c4vcm3GMOkP13/gAh4yef5H3h9XRhmtvAEbdDOIpyNxQkh6u0QuAT7wrFyuFW +20QCK1MjyevqioQ3z3MrqAx5r4Qn+cWOdF9VqwDH/KoY89j2oyu3SETnPS5AJFHZcdD X0qDb2q1Xj5VDVp+FhJpKWtxS0cDW1IfuRxzUKe2RfjEsyhAzOCuvmK7AnyaJoryLbVG ZpsQ== X-Gm-Message-State: AJaThX4ex7T9v1L10SWzIvJFP4PIqO7KGNRtz/M07/61ALhJLLgFbcOt oJ9VcZ5owWFdajdkQqxfRM/Vmg== X-Google-Smtp-Source: AGs4zMZdY8T04L6E5UZLH584nHDsCxaDMtnpJ95Vq7o0tNegLrnjh9RcfSPi+x2MMMYDPwvrTyGj4A== X-Received: by 10.223.136.38 with SMTP id d35mr8364861wrd.36.1512227097119; Sat, 02 Dec 2017 07:04:57 -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 b16sm12572601wrd.69.2017.12.02.07.04.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 02 Dec 2017 07:04:56 -0800 (PST) Subject: Re: [HACKERS] Custom compression methods To: Andres Freund , Robert Haas Cc: Ildus Kurbangaliev , "pgsql-hackers@postgresql.org" , Ildar Musin References: <0158242e-af45-c0f0-4fbb-4d54ca219cfd@2ndquadrant.com> <20171128162918.7104d0f9@wp.localdomain> <9a0745ab-5b62-d81f-3a6d-ec0929a4a99d@2ndquadrant.com> <20171130182009.1b492eb2@wp.localdomain> <9dc0d3ba-5fa2-a7b0-5789-fff3c60cef1c@2ndquadrant.com> <20171201215217.7ic4izdvj5cishgx@alap3.anarazel.de> From: Tomas Vondra Message-ID: <5cb1995e-a202-2739-bf46-1b6950e5bdb6@2ndquadrant.com> Date: Sat, 2 Dec 2017 16:04:52 +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: <20171201215217.7ic4izdvj5cishgx@alap3.anarazel.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 12/01/2017 10:52 PM, Andres Freund wrote: > On 2017-12-01 16:14:58 -0500, Robert Haas wrote: >> Honestly, if we can give everybody a 4% space reduction by >> switching to lz4, I think that's totally worth doing -- but let's >> not make people choose it, let's make it the default going forward, >> and keep pglz support around so we don't break pg_upgrade >> compatibility (and so people can continue to choose it if for some >> reason it works better in their use case). That kind of improvement >> is nothing special in a specific workload, but TOAST is a pretty >> general-purpose mechanism. I have become, through a few bitter >> experiences, a strong believer in the value of trying to reduce our >> on-disk footprint, and knocking 4% off the size of every TOAST >> table in the world does not sound worthless to me -- even though >> context-aware compression can doubtless do a lot better. > > +1. It's also a lot faster, and I've seen way way to many workloads > with 50%+ time spent in pglz. > TBH the 4% figure is something I mostly made up (I'm fake news!). On the mailing list archive (which I believe is pretty compressible) I observed something like 2.5% size reduction with lz4 compared to pglz, at least with the compression levels I've used ... Other algorithms (e.g. zstd) got significantly better compression (25%) compared to pglz, but in exchange for longer compression. I'm sure we could lower compression level to make it faster, but that will of course hurt the compression ratio. I don't think switching to a different compression algorithm is a way forward - it was proposed and explored repeatedly in the past, and every time it failed for a number of reasons, most of which are still valid. Firstly, it's going to be quite hard (or perhaps impossible) to find an algorithm that is "universally better" than pglz. Some algorithms do work better for text documents, some for binary blobs, etc. I don't think there's a win-win option. Sure, there are workloads where pglz performs poorly (I've seen such cases too), but IMHO that's more an argument for the custom compression method approach. pglz gives you good default compression in most cases, and you can change it for columns where it matters, and where a different space/time trade-off makes sense. Secondly, all the previous attempts ran into some legal issues, i.e. licensing and/or patents. Maybe the situation changed since then (no idea, haven't looked into that), but in the past the "pluggable" approach was proposed as a way to address this. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services