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 1hDu0h-0007li-P3 for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Apr 2019 16:54:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hDu0g-0002vd-EN for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Apr 2019 16:54:10 +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 1hDu0f-0002vP-Tt for pgsql-hackers@lists.postgresql.org; Tue, 09 Apr 2019 16:54:10 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hDu0c-000096-B2 for pgsql-hackers@postgresql.org; Tue, 09 Apr 2019 16:54:08 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id CC4DB21C2873; Tue, 9 Apr 2019 19:54:04 +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 9E0B921C1C3A; Tue, 9 Apr 2019 19:54:04 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1554828844; bh=h8q6Wozupx1XisA70XPKbCBGkz/NHAU01Tfq/yesncw=; h=Subject:To:References:From:Date:In-Reply-To; b=YzvRHCiGzwbWTWhAIg6Zli4YOUfMtSdQL9doyNB4Dow4JNGhf1pgExzNgrBpiIXUD OXLloUhP+HUUAaNxM2AOi6WqbxzOvF+YQeoORmlflrRA02r9+g54U3F/dR2i51oTSh zewboRuA5518wSBbStpbG33ZrUwiCWAok0/Su8mc= Subject: Re: Zedstore - compressed in-core columnar storage To: Heikki Linnakangas , Ashwin Agrawal , PostgreSQL mailing lists References: <50cc2e44-774b-c636-6c47-83bf4596648f@iki.fi> From: Konstantin Knizhnik Message-ID: Date: Tue, 9 Apr 2019 19:54:03 +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: <50cc2e44-774b-c636-6c47-83bf4596648f@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 19:19, Heikki Linnakangas wrote: > On 09/04/2019 18:00, Konstantin Knizhnik wrote: >> 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 >> >> No wonder that zedstore shows the worst results: >> >> lineitem                                      6240.261 ms >> lineitem_projection                    5390.446 ms >> zedstore_lineitem_projection   23310.341 ms >> vops_lineitem_projection             439.731 ms >> >> Updated version of vstore_bench.sql is attached (sorry, there was some >> errors in previous version of this script). > > I tried this quickly, too. With default work_mem and no parallelism, > and 1 gb table size, it seems that the query chooses a different plan > with heap and zedstore, with a sort+group for zedstore and hash agg > for heap. There's no ANALYZE support in zedstore yet, and we haven't > given much thought to parallelism either. With work_mem='1GB' and no > parallelism, both queries use a hash agg, and the numbers are much > closer than what you saw, about 6 s for heap, and 9 s for zedstore. > > - Heikki Yes, you was right. The plan for zedstore uses  GroupAggregate instead of  HashAggregate. Increasing work_mem force optimizer to use HashAggregate in all cases. But it doesn't prevent memory overflow in my case. And it is very strange to me, because there are just 4 groups in the result, so it should not consume any  memory. Yet another strange thing is that size of zedstore_table is 10Gb according to pg_relation_size. Q1 query access only some some subset of "lineitem" columns, not touching the largest ones (with text). I have configured 12Gb shared buffers. And all this 11Gb are used! Looks like all columns are fetched from the disk. And looks like except this 11Gb of shard data, backend (and each parallel worker) is also consuming several gigabytes of heap memory. As a result total size of used memory during parallel query execution with 4 workers exceeds 20GB and cause terrible swapping at my system. -- Konstantin Knizhnik Postgres Professional: http://www.postgrespro.com The Russian Postgres Company