Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDElv-0006oH-Eo for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Sep 2019 21:24:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iDEls-0007TF-V5 for pgsql-hackers@arkaria.postgresql.org; Wed, 25 Sep 2019 21:24:24 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDEls-0007SU-MP for pgsql-hackers@lists.postgresql.org; Wed, 25 Sep 2019 21:24:24 +0000 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iDElo-0000nI-D0 for pgsql-hackers@postgresql.org; Wed, 25 Sep 2019 21:24:23 +0000 Received: by mail-wr1-x443.google.com with SMTP id i1so322219wro.4 for ; Wed, 25 Sep 2019 14:24:19 -0700 (PDT) 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=j4FQYgoFWTzkN+oTUnAn7O3IDnDM/nqfyjoNcQUvtJI=; b=f85RgTXAY+vnpbdxa66vlyr6LS9uNIzNexy+cc1ukidkEJKMPTkVlXBzaMyL6FiLEt 0TJJAgS6pOwzh636JqlwHscSgsMSKz/wWCZwfbkOKVT/N8o+6Pp1xCi0TpP/GdccVJ1W gi+gaSdUNB0gPlqEDQTXrGsuSfcKv0HH8vp8lf1kRzyADdeulMD+fDzM/rE8DZSYXvFD q0rc58nbdVsAbydVoRZMVRQMM8PB2snqULE1XnEcF4pcSMQSAN/fLVYihDEyd+/UoVPN CuuAlfmAbKGuQ/vcmwrfssZkCkpaytdkfzFcMnMKzg/sVObNTDBA4jzJ7iAy8thSG2SA 3nCA== 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=j4FQYgoFWTzkN+oTUnAn7O3IDnDM/nqfyjoNcQUvtJI=; b=J7L4V4lQR2iynZUCR3XoD2AF3FSEjoAXxtiUhyPQmytG+yoPgayMJOSAENmUbaPLNC lFXkO6gsCl2hAP4N35/FmNygcsE2UwKRmofpVtzkkZU0so/hBqVA+KhzUC15v1aHoasN Z1J0T6IWlXeGOBdGNflaWl8uDFKYdZioDi3W1SUqsaRgD4yH2QUmJKu6Ee+ILbtxVinH Q7IJOA2ykQS5+ziVlGAJGKmjcQWPjqdIiO7PamQD8JtQEmhh4zJZ4YfRPRS/eilrJn3I r27gKebOVQ42nSlyGSRC3jFXv6m5Hrz6M8D9U+7KdD+0Gv/cDFs5SvRUlQ0wZE34fjGl 5okA== X-Gm-Message-State: APjAAAUaW/T3LDYxL6OBElRuNqZnFcgsHBwX9ko0xCEVcO2zdnnFwUwc qmPqT7hzSYad8J3kfvBY+eBWJA== X-Google-Smtp-Source: APXvYqx5lpvFDsDyPzveE44mHQ8b44NmEPftYaTBVVJTBI9zDi1qTBOEOAl5G05M8WEKMdxk6vHRlg== X-Received: by 2002:a5d:678d:: with SMTP id v13mr257148wru.133.1569446659361; Wed, 25 Sep 2019 14:24:19 -0700 (PDT) Received: from ?IPv6:2a02:8308:13b:9400:54a1:714f:b878:5d89? ([2a02:8308:13b:9400:54a1:714f:b878:5d89]) by smtp.gmail.com with ESMTPSA id h63sm470073wmf.15.2019.09.25.14.24.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Sep 2019 14:24:18 -0700 (PDT) Subject: Re: pglz performance To: Andres Freund Cc: Tomas Vondra , Andrey Borodin , Konstantin Knizhnik , Michael Paquier , pgsql-hackers , Vladimir Leskov References: <20190802170039.o4pabnzm4xy3z7uj@development> <20190802171258.nob5zo2vu7siqo2b@alap3.anarazel.de> <20190802175239.5ds6rhdso6hwy4vk@development> <20190802182003.u477q6itwudieqxf@alap3.anarazel.de> <20190802194859.qxzxq2achzottkup@development> <20190804115237.nliwf6hhaqfd62ps@development> <20190804221533.3lpbs5krfnjisflj@alap3.anarazel.de> <20190805072625.pzebnrs3fvk5wjen@alap3.anarazel.de> From: Petr Jelinek Message-ID: <704b2f0a-fef3-cee0-bd55-b5704074f4c3@2ndquadrant.com> Date: Wed, 25 Sep 2019 23:24:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190805072625.pzebnrs3fvk5wjen@alap3.anarazel.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 05/08/2019 09:26, Andres Freund wrote: > Hi, > > On 2019-08-05 00:19:28 +0200, Petr Jelinek wrote: >> It carries that information inside the compressed value, like I said in the >> other reply, that's why the extra byte. > > I'm not convinced that that is a good plan - imo the reference to the > compressed data should carry that information. > > I.e. in the case of toast, at least toast pointers should hold enough > information to determine the compression algorithm. And in the case of > WAL, the WAL record should contain that. > Point taken. > > For external datums I suggest encoding the compression method as a > distinct VARTAG_ONDISK_COMPRESSED, and then have that include the > compression method as a field. So the new reads/writes will use this and reads of old format won't change? Sounds fine. > > For in-line compressed values (so VARATT_IS_4B_C), doing something > roughly like you did, indicating the type of metadata following using > the high bit sounds reasonable. But I think I'd make it so that if the > highbit is set, the struct is instead entirely different, keeping a full > 4 byte byte length, and including the compression type header inside the > struct. Perhaps I'd combine the compression type with the high-bit-set > part? So when the high bit is set, it'd be something like > > { > int32 vl_len_; /* varlena header (do not touch directly!) */ > > /* > * Actually only 7 bit, the high bit determines whether this > * is the old compression header (if unset), or this type of header > * (if set). > */ > uint8 type; > > /* > * Stored as uint8[4], to avoid unnecessary alignment padding. > */ > uint8[4] length; > > char va_data[FLEXIBLE_ARRAY_MEMBER]; > } > Won't this break BW compatibility on big-endian (if I understand corretly what you are trying to achieve here)? > I think it's worth spending some effort trying to get this right - we'll > be bound by design choices for a while. > Sure, however I am not in business of redesigning TOAST from scratch right now, even if I do agree that the current header is far from ideal. -- Petr Jelinek 2ndQuadrant - PostgreSQL Solutions for the Enterprise https://www.2ndQuadrant.com/