Thread: BRIN Scan: Optimize memory allocation in function 'bringetbitmap'

BRIN Scan: Optimize memory allocation in function 'bringetbitmap'

From
"Jinyu Zhang"
Date:
<div style="line-height:1.7;color:#000000;font-size:14px;font-family:Arial"><br />BRIN Scan: Optimize memory allocation
infunction 'bringetbitmap'.<br />We can allocate memory for some pointer before do long loop instead of allocating <br
/>memoryin long loop.<br /><br />Before optimizing code (warm run)<br />postgres=# select count(*) from lineitem where
l_orderkey=1;<br/> count <br />-------<br />     6<br />(1 row)<br /><br />Time: 456.219 ms<br /><br />After optimizing
code(warm run)<br />postgres=# select count(*) from lineitem where l_orderkey=1;<br /> count <br />-------<br />    
6<br/>(1 row)<br /><br />Time: 349.219 ms<br /><br />The following shows the DDL of this test case.<br />CREATE TABLE
LINEITEM( L_ORDERKEY    INTEGER NOT NULL,<br />                             L_PARTKEY     INTEGER NOT NULL,<br
/>                            L_SUPPKEY     INTEGER NOT NULL,<br />                             L_LINENUMBER  INTEGER
NOTNULL,<br />                             L_QUANTITY    DECIMAL(15,2) NOT NULL,<br />                            
L_EXTENDEDPRICE DECIMAL(15,2) NOT NULL,<br />                             L_DISCOUNT    DECIMAL(15,2) NOT NULL,<br
/>                            L_TAX         DECIMAL(15,2) NOT NULL,<br />                             L_RETURNFLAG 
CHAR(1)NOT NULL,<br />                             L_LINESTATUS  CHAR(1) NOT NULL,<br />                            
L_SHIPDATE   DATE NOT NULL,<br />                             L_COMMITDATE  DATE NOT NULL,<br
/>                            L_RECEIPTDATE DATE NOT NULL,<br />                             L_SHIPINSTRUCT CHAR(25)
NOTNULL,<br />                             L_SHIPMODE     CHAR(10) NOT NULL,<br />                            
L_COMMENT     VARCHAR(44) NOT NULL);<br /><br />copy lineitem from '/home/jinyu/mywork/dbgen/lineitem.tbl' delimiter
'|';<br/>create index brinLineitem on lineitem using brin(L_ORDERKEY) with(pages_per_range = 1);<br /><br />Jinyu
Zhang<br/></div><br /><br /><span title="neteasefooter"><p><span style="color:#000011;font-family:simsun,
serif;font-size:12px"><a
href="http://rd.da.netease.com/redirect?t=ORBmhG&p=y7fo42&proId=1024&target=http%3A%2F%2Fwww.kaola.com%2Factivity%2Fdetail%2F4650.html%3Ftag%3Dea467f1dcce6ada85b1ae151610748b5"
target="_blank">网易考拉iPhone6s玫瑰金5288元,现货不加价</a></span></span>

Re: BRIN Scan: Optimize memory allocation in function 'bringetbitmap'

From
Simon Riggs
Date:
On 27 September 2015 at 02:15, Jinyu Zhang <beijing_pg@163.com> wrote:

BRIN Scan: Optimize memory allocation in function 'bringetbitmap'.
We can allocate memory for some pointer before do long loop instead of allocating
memory in long loop.

Before optimizing code (warm run)
postgres=# select count(*) from lineitem where l_orderkey=1;
 count
-------
     6
(1 row)

Time: 456.219 ms

After optimizing code (warm run)
postgres=# select count(*) from lineitem where l_orderkey=1;
 count
-------
     6
(1 row)

Time: 349.219 ms

Patch?
 
--
Simon Riggs                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Re: BRIN Scan: Optimize memory allocation in function 'bringetbitmap'

From
zhangjinyu
Date:
Sorry,  I forgot attaching patch. But I have send path in another thread.
Please see this thread "Patch: Optimize memory allocation in function
'bringetbitmap' ".





--
View this message in context:
http://postgresql.nabble.com/BRIN-Scan-Optimize-memory-allocation-in-function-bringetbitmap-tp5867536p5867648.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.



Re: BRIN Scan: Optimize memory allocation in function 'bringetbitmap'

From
zhangjinyu
Date:
I forgot disable-c-assert last test.  
The following show the test result when disable-c-assert.
After optimize code (warm run)
postgres=# select count(*) from lineitem where l_orderkey=1;count
-------    6
(1 row)

Time: 327.143 ms
Before optimizing code (warm run)
postgres=# select count(*) from lineitem where l_orderkey=1;count
-------    6
(1 row)

Time: 404.323 ms

Here is the patch. patch_optimize_mem.patch_optimize_mem
<http://postgresql.nabble.com/file/n5867980/patch_optimize_mem.patch_optimize_mem>  

Jinyu Zhang



--
View this message in context:
http://postgresql.nabble.com/BRIN-Scan-Optimize-memory-allocation-in-function-bringetbitmap-tp5867536p5867980.html
Sent from the PostgreSQL - hackers mailing list archive at Nabble.com.



Re: Re: BRIN Scan: Optimize memory allocation in function 'bringetbitmap'

From
Simon Riggs
Date:
On 28 September 2015 at 15:47, zhangjinyu <beijing_pg@163.com> wrote:
Sorry,  I forgot attaching patch. But I have send path in another thread.
Please see this thread "Patch: Optimize memory allocation in function
'bringetbitmap' ".

Please don't submit a patch on a separate thread. Thanks.

Let's close this thread, so we have just one. 

--
Simon Riggs                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services