Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aikjl-00019h-8e for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Mar 2016 15:30:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1aikjk-0006oV-K6 for pgsql-hackers@arkaria.postgresql.org; Wed, 23 Mar 2016 15:30:20 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1aikji-0006nY-MN for pgsql-hackers@postgresql.org; Wed, 23 Mar 2016 15:30:18 +0000 Received: from newmail.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aikjd-0003XE-Rt for pgsql-hackers@postgresql.org; Wed, 23 Mar 2016 15:30:17 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 16D9821C7305; Wed, 23 Mar 2016 18:30:13 +0300 (MSK) Received: from mail.postgrespro.ru ([127.0.0.1]) by localhost (mail.postgrespro.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rzCeUjlOIEvs; Wed, 23 Mar 2016 18:30:09 +0300 (MSK) Received: from [192.168.27.48] (unknown [192.168.27.1]) by mail.postgrespro.ru (Postfix) with ESMTPSA id E299521C72EC; Wed, 23 Mar 2016 18:30:08 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1458747008; bh=wlEQheHhTzYC4V0zheZkrZkLj54t/sWUe9rehlMgnqY=; h=Subject:To:References:From:Date:In-Reply-To; b=boqWdICGnn/EqXAGujuqMykucrzn6kvaYJyFhYWDigGxWWmgnWw0uMdYfnSbXKUU2 o0z2nt1m9aSDv3/8100ZyCn/0/0Du/6cbrbB139eWXUIgTm7qB396Wi3weKqsQaUZ0 xQYLRC/fVtGP33lK45ajD+irevFHWo8Nia/LarSQ= Subject: Re: [WIP] Effective storage of duplicates in B-tree index. To: Anastasia Lubennikova , David Steele , pgsql-hackers@postgresql.org References: <55E4051B.7020209@postgrespro.ru> <56AA2081.1080001@postgrespro.ru> <56AA3E06.8040006@postgrespro.ru> <56AB6D30.2040900@postgrespro.ru> <20160129184733.2ca9026a@fujitsu> <56AB9866.6050207@postgrespro.ru> <56C5FCE1.1090509@postgrespro.ru> <56C5FF80.5050905@postgrespro.ru> <56E6B64E.6000101@pgmasters.net> <56E84834.2070003@postgrespro.ru> <56EC38A9.9030303@postgrespro.ru> From: Alexandr Popov Message-ID: <56F2B686.9070602@postgrespro.ru> Date: Wed, 23 Mar 2016 18:30:14 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56EC38A9.9030303@postgrespro.ru> Content-Type: multipart/alternative; boundary="------------040404030907000904050607" X-Pg-Spam-Score: -2.0 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org This is a multi-part message in MIME format. --------------040404030907000904050607 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit On 18.03.2016 20:19, Anastasia Lubennikova wrote: > Please, find the new version of the patch attached. Now it has WAL > functionality. > > Detailed description of the feature you can find in README draft > https://goo.gl/50O8Q0 > > This patch is pretty complicated, so I ask everyone, who interested in > this feature, > to help with reviewing and testing it. I will be grateful for any > feedback. > But please, don't complain about code style, it is still work in > progress. > > Next things I'm going to do: > 1. More debugging and testing. I'm going to attach in next message > couple of sql scripts for testing. > 2. Fix NULLs processing > 3. Add a flag into pg_index, that allows to enable/disable compression > for each particular index. > 4. Recheck locking considerations. I tried to write code as less > invasive as possible, but we need to make sure that algorithm is still > correct. > 5. Change BTMaxItemSize > 6. Bring back microvacuum functionality. > Hi, hackers. It's my first review, so do not be strict to me. I have tested this patch on the next table: create table message ( id serial, usr_id integer, text text ); CREATE INDEX message_usr_id ON message (usr_id); The table has 10000000 records. I found the following: The less unique keys the less size of the table. Next 2 tablas demonstrates it. New B-tree Count of unique keys (usr_id), index“s size , time of creation 10000000 ;"214 MB" ;"00:00:34.193441" 3333333 ;"214 MB" ;"00:00:45.731173" 2000000 ;"129 MB" ;"00:00:41.445876" 1000000 ;"129 MB" ;"00:00:38.455616" 100000 ;"86 MB" ;"00:00:40.887626" 10000 ;"79 MB" ;"00:00:47.199774" Old B-tree Count of unique keys (usr_id), index“s size , time of creation 10000000 ;"214 MB" ;"00:00:35.043677" 3333333 ;"286 MB" ;"00:00:40.922845" 2000000 ;"300 MB" ;"00:00:46.454846" 1000000 ;"278 MB" ;"00:00:42.323525" 100000 ;"287 MB" ;"00:00:47.438132" 10000 ;"280 MB" ;"00:01:00.307873" I inserted data randomly and sequentially, it did not influence the index's size. Time of select, insert and update random rows is not changed. It is great, but certainly it needs some more detailed study. Alexander Popov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company --------------040404030907000904050607 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: 8bit

On 18.03.2016 20:19, Anastasia Lubennikova wrote:
Please, find the new version of the patch attached. Now it has WAL functionality.

Detailed description of the feature you can find in README draft https://goo.gl/50O8Q0

This patch is pretty complicated, so I ask everyone, who interested in this feature,
to help with reviewing and testing it. I will be grateful for any feedback.
But please, don't complain about code style, it is still work in progress.

Next things I'm going to do:
1. More debugging and testing. I'm going to attach in next message couple of sql scripts for testing.
2. Fix NULLs processing
3. Add a flag into pg_index, that allows to enable/disable compression for each particular index.
4. Recheck locking considerations. I tried to write code as less invasive as possible, but we need to make sure that algorithm is still correct.
5. Change BTMaxItemSize
6. Bring back microvacuum functionality.



Hi, hackers.

It's my first review, so do not be strict to me.

I have tested this patch on the next table:
create table message
    (
        id        serial,
        usr_id        integer,
        text        text
    );
CREATE INDEX message_usr_id ON message (usr_id);
The table has 10000000 records.

I found the following:
The less unique keys the less size of the table.

Next 2 tablas demonstrates it.
New B-tree
Count of unique keys (usr_id), index“s size , time of creation
10000000    ;"214 MB"    ;"00:00:34.193441"
3333333      ;"214 MB"    ;"00:00:45.731173"
2000000      ;"129 MB"    ;"00:00:41.445876"
1000000      ;"129 MB"    ;"00:00:38.455616"
100000        ;"86 MB"      ;"00:00:40.887626"
10000          ;"79 MB"      ;"00:00:47.199774"

Old B-tree
Count of unique keys (usr_id), index“s size , time of creation
10000000    ;"214 MB"    ;"00:00:35.043677"
3333333      ;"286 MB"    ;"00:00:40.922845"
2000000      ;"300 MB"    ;"00:00:46.454846"
1000000      ;"278 MB"    ;"00:00:42.323525"
100000        ;"287 MB"    ;"00:00:47.438132"
10000          ;"280 MB"    ;"00:01:00.307873"

I inserted data  randomly and sequentially, it did not influence the index's size.
Time of select, insert and update random rows is not changed. It is great, but certainly it needs some more detailed study.
 
Alexander Popov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company


--------------040404030907000904050607--