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 1hDswH-000400-R8 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Apr 2019 15:45:34 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hDswF-0006uH-Vi for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Apr 2019 15:45:31 +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 1hDswF-0006ts-FD for pgsql-hackers@lists.postgresql.org; Tue, 09 Apr 2019 15:45:31 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hDswC-0006tH-9y for pgsql-hackers@postgresql.org; Tue, 09 Apr 2019 15:45:31 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id B21E721C3D7E; Tue, 9 Apr 2019 18:45:26 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from [192.168.27.200] (gw.postgrespro.ru [93.174.131.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 86E2121C3D70; Tue, 9 Apr 2019 18:45:26 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1554824726; bh=pPEo/N+vJvZyhpPqEKSKwFwJdJq+hlhWKIyNqPA2VxY=; h=Subject:To:References:From:Date:In-Reply-To; b=mAwnnAhI4Hr2NhYBuE3dz7iXfezitzOltl4qLkcw/CWzOrBjh8uOIpiPXoyMvSs7F hSHjBLGDLprjWJ4zl9wkBErHqOGBCtwj98BlHUHlMRWoB7hXUHGj8ChP30QC8C3gGc tS+uP4oryqJlntmshVnPYh3Pp2W5CfTXy87zRyvI= Subject: Re: Zedstore - compressed in-core columnar storage To: Heikki Linnakangas , Ashwin Agrawal , PostgreSQL mailing lists References: <29097cfc-4e60-57c1-12e8-074d82bd6f33@iki.fi> From: Konstantin Knizhnik Message-ID: <3978b57e-fe25-ca6b-f56c-48084417e115@postgrespro.ru> Date: Tue, 9 Apr 2019 18:45:26 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <29097cfc-4e60-57c1-12e8-074d82bd6f33@iki.fi> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 09.04.2019 18:08, Heikki Linnakangas wrote: > On 09/04/2019 18:00, Konstantin Knizhnik wrote: >> On 09.04.2019 17:09, Konstantin Knizhnik wrote: >>> standard Postgres heap and my VOPS extension. >>> As test data I used TPC-H benchmark (actually only one lineitem table >>> generated with tpch-dbgen utility with scale factor 10 (~8Gb database). >>> I attached script which I have use to populate data (you have to to >>> download, build and run tpch-dbgen yourself, also you can comment code >>> related with VOPS). > > Cool, thanks! > >>> Unfortunately I failed to load data in zedstore: >>> >>> postgres=# insert into zedstore_lineitem_projection (select >>> l_shipdate,l_quantity,l_extendedprice,l_discount,l_tax,l_returnflag::"char",l_linestatus::"char" >>> >>> from lineitem); >>> psql: ERROR:  compression failed. what now? >>> Time: 237804.775 ms (03:57.805) > > Yeah, it's still early days, it will crash and burn in a lot of cases. > We wanted to publish this early, to gather ideas and comments on the > high level design, and to validate that the table AM API that's in v12 > is usable. > >> Looks like the original problem was caused by internal postgres >> compressor: I have not configured Postgres to use lz4. >> When I configured Postgres --with-lz4, data was correctly inserted in >> zedstore table, but looks it is not compressed at all: >> >> postgres=# select pg_relation_size('zedstore_lineitem_projection'); >>    pg_relation_size >> ------------------ >>          9363010640 > > The single-insert codepath isn't very optimized yet. If you populate > the table with large "INSERT ... SELECT ...", you end up with a huge > undo log. Try loading it with COPY. > > You can also see how many pages of each type there is with: > > select count(*), pg_zs_page_type('zedstore_lineitem_projection', g) >   from generate_series(0, > pg_table_size('zedstore_lineitem_projection') / 8192 - 1) g group by 2; > > - Heikki postgres=# copy zedstore_lineitem from '/mnt/data/lineitem.tbl' delimiter '|' csv; COPY 59986052 Time: 232802.257 ms (03:52.802) postgres=# select pg_relation_size('zedstore_lineitem');  pg_relation_size ------------------       10346504192 (1 row) postgres=# select count(*), pg_zs_page_type('zedstore_lineitem', g)   from generate_series(0, pg_table_size('zedstore_lineitem') / 8192 - 1) g group by 2;   count  | pg_zs_page_type ---------+-----------------        1 | META  1262308 | BTREE      692 | UNDO (3 rows) And now performance is much worser: Time: 99819.476 ms (01:39.819) It is strange, because the main advantage of columnar store is that it has to fetch only accessed rows. What I see is that in non-parallel mode (max_parallel_workers_per_gather = 0) backend consumes about 11GB of memory. It fits in my desktop RAM (16GB) and speed is ~58 seconds. But one I start 4 parallel workers, them cause huge swapping:   PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND 28195 knizhnik  20   0 11.823g 6.553g 5.072g D   7.6 42.2   0:17.19 postgres 28074 knizhnik  20   0 11.848g 6.726g 5.223g D   7.3 43.3   4:14.96 postgres 28192 knizhnik  20   0 11.854g 6.586g 5.075g D   7.3 42.4   0:17.18 postgres 28193 knizhnik  20   0 11.870g 6.594g 5.064g D   7.3 42.4   0:17.19 postgres 28194 knizhnik  20   0 11.854g 6.589g 5.078g D   7.3 42.4   0:17.09 postgres which is also strange because data should be present in shared buffers. -- Konstantin Knizhnik Postgres Professional: http://www.postgrespro.com The Russian Postgres Company