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 1hG6B9-0000Kk-MY for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Apr 2019 18:18:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hG6B8-0004hd-DS for pgsql-hackers@arkaria.postgresql.org; Mon, 15 Apr 2019 18:18:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hG6B7-0004hU-Sx for pgsql-hackers@lists.postgresql.org; Mon, 15 Apr 2019 18:18:02 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hG6B4-0002kl-Ib for pgsql-hackers@postgresql.org; Mon, 15 Apr 2019 18:18:00 +0000 Received: by mail-wr1-x441.google.com with SMTP id h4so23206988wre.7 for ; Mon, 15 Apr 2019 11:17:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=sHU0eVA+kGFvfPDz6FuJdcMYqFZ2PwVI4hXf3ncd1ls=; b=OdQjh4R0vIrwNsLVZqgrjebXGrsFSrl1yy5QQx8Ya7kbwErBiJPqsQ4MB/MY+AHLta MJrd1MYs1bDKr11BRlsrhTcK/qUrXDWpCSuJI+ceAaK94L15pHIApgUuu2QNWgAlme+w FwpSP9BDm+wZWNhh/88VD/WBRsrbAVSYPMdl/cjBwLsi/YoAQW35Azn+b11gcEKFc4+m aUEjFITuOMrTH2s6qFOIUipHwMBK4a/O+hdulBQVClHkLh8NjILYMW7vStcsVLSZ29Ot NUDLcdCBY/rqyhqz0BE8McW0CzXGh7UMqRqAtn8ic0iOeeABlU+6mkyEdGwesTn2E24O E9wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=sHU0eVA+kGFvfPDz6FuJdcMYqFZ2PwVI4hXf3ncd1ls=; b=VLki3SfpdmFGVlgXxTqOkntWGwKYC2sUw0hkrRxfGn84u+iilX8wXpnhOI3PkWrtZD ZHFeGnRkz7RDOdv86/SildGV6p+zGqVhZwKpRC+iw7l6jIXOGcEhGePulvOeJZljoB/d bc57LnPG/l8B87Hh50kZBGAo3uYhkNrO2bhvlBM8v712a0fahGsgt81dM0LX04Rb01Qw Rh+JPWZsoXvrtAQe11PXem7Jk82DZa5zYNTq1RJO2vpwPbRzrUTIak2G2JG5fI72lvg3 G+t+XadLhosJqkIcrqGGcViIZkHYAI7X7vJ9YzKhzlo0JsPZkMFxTieRaR6HHo++alPo WR4g== X-Gm-Message-State: APjAAAXJ1yCk0n/kGHTvYUaTNzp7wsTQZe86OHZyFD5gJYwkL7rONPfC g/rzKuQpklNfkHzdTN9kO6OOqw== X-Google-Smtp-Source: APXvYqz6ZUlfbr4nBFn9MZN+HBBNODsn7/EOK1RPlzx8OEgzZunMlGX9eGhkwAw/oVuXkVQ3pHPzjA== X-Received: by 2002:adf:cc85:: with SMTP id p5mr45539994wrj.101.1555352277003; Mon, 15 Apr 2019 11:17:57 -0700 (PDT) Received: from localhost (ip-86-49-243-43.net.upcbroadband.cz. [86.49.243.43]) by smtp.gmail.com with ESMTPSA id h9sm13992266wmb.5.2019.04.15.11.17.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 15 Apr 2019 11:17:56 -0700 (PDT) Date: Mon, 15 Apr 2019 20:17:54 +0200 From: Tomas Vondra To: Ashwin Agrawal Cc: Heikki Linnakangas , Tom Lane , Mark Kirkwood , PostgreSQL mailing lists Subject: Re: Zedstore - compressed in-core columnar storage Message-ID: <20190415181754.6dfp5lr6obpzutub@development> References: <6A2B85A8-1ABD-4F85-981E-C94172D662FD@pivotal.io> <11257.1554994460@sss.pgh.pa.us> <20190414163947.owdw4gyjui36rakf@development> <20190415173254.nlnk2xqhgt7c5pta@development> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: NeoMutt/20180716-1444-295967 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Apr 15, 2019 at 10:50:21AM -0700, Ashwin Agrawal wrote: > On Mon, Apr 15, 2019 at 10:33 AM Tomas Vondra > wrote: > > ... > > I see. Perhaps it'd be better to call the flag ZSBT_CONTAINER, when it > means "this is a container". And then have another flag to track whether > the container is compressed or not. But as I suggested elsewhere in this > thread, I think it might be better to store some ID of the compression > algorithm used instead of a simple flag. > > FWIW when I had to deal with incremental compression (adding data into > already compressed buffers), which is what seems to be happening here, I > found it very useful/efficient to allow partially compressed buffers and > only trigger recompressin when absolutely needed. > > Applied to this case, the container would first store compressed chunk, > followed by raw (uncompressed) data. Say, like this: > > ZSContainerData { > >     // header etc. > >     int nbytes;         /* total bytes in data */ >     int ncompressed;    /* ncompressed <= nbytes, fully compressed when >                          * (ncompressed == nbytes) */ > >     char data[FLEXIBLE_ARRAY_MEMBER]; > } > > When adding a value to the buffer, it'd be simply appended to the data > array. When the container would grow too much (can't fit on the page or > something), recompression is triggered. > > I think what you suggested here is exactly how its handled currently, just > the mechanics are little different. Plain items are added to page as > insertions are performed. Then when page becomes full, compression is > triggerred container item is created for them to store the compressed > data. Then new insertions are stored as plain items, once again when page > becomes full, they are compressed and container item created for it. So, > never, compressed data is attempted to be compressed again. So, on page > plain items are acting as data section you mentioned above. A page can > have mix of n plain and n container items. Maybe. I'm not going to pretend I fully understand the internals. Does that mean the container contains ZSUncompressedBtreeItem as elements? Or just the plain Datum values? regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services