PostgreSQL Performance Presentation
9.5devel Edition Mark Wong Consultant, 2ndQuadrant & Contributor, PostgreSQL 10 March 2015
c 2ndQuadrant, Ltd. SF PGDAY 2015 1 / 50
PostgreSQL Performance Presentation 9.5devel Edition Mark Wong - - PowerPoint PPT Presentation
PostgreSQL Performance Presentation 9.5devel Edition Mark Wong Consultant, 2ndQuadrant & Contributor, PostgreSQL 10 March 2015 2ndQuadrant, Ltd. c SF PGDAY 2015 1 / 50 Agenda Background Patches to test The test suite
9.5devel Edition Mark Wong Consultant, 2ndQuadrant & Contributor, PostgreSQL 10 March 2015
c 2ndQuadrant, Ltd. SF PGDAY 2015 1 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 2 / 50
This presentation made possible by the AXLE1 project:
1http://axleproject.eu/
c 2ndQuadrant, Ltd. SF PGDAY 2015 3 / 50
− Scalability engineering—autopartitioning,
compression
− Security, privacy, and audit techniques − Visual analytics − Advanced architectures for hardware and
software
− 2ndQuadrant − Barcelona Supercomputing Center − PortaVita − University of Manchester − University of Ljubljana c 2ndQuadrant, Ltd. SF PGDAY 2015 4 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 5 / 50
Patches tested in this presentation are intended to help the performance of large database systems:
− BRIN indexes
− Concurrent hash table for buffer lookups − Wait free LWLocks
memory by using spin locks or semaphores
c 2ndQuadrant, Ltd. SF PGDAY 2015 6 / 50
2http://goo.gl/yUwav9
c 2ndQuadrant, Ltd. SF PGDAY 2015 7 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 8 / 50
Best case scenario:
− A table recording sales orders − Use BRIN on the DATE column representing
when an order was placed
c 2ndQuadrant, Ltd. SF PGDAY 2015 9 / 50
B-tree BRIN
c 2ndQuadrant, Ltd. SF PGDAY 2015 10 / 50
− Lookups performed using memory barriers
instead of locks
− Inserts and deletes (to the buffer table) use
atomic operations instead of locks
3http://goo.gl/9naq5c
c 2ndQuadrant, Ltd. SF PGDAY 2015 11 / 50
4http://goo.gl/8bf3CN
c 2ndQuadrant, Ltd. SF PGDAY 2015 12 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 13 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 14 / 50
Barcelona Supercomputing Center
− 2 x Intel Xeon E5-2670, Sandy Bridge DP
, 2.6Ghz 8 Core/16 Threads, 3.3Ghz Turbo, 8GT/s QPI, 20MB cache, 115W
− 256 GB RAM − 120TB storage connected via 10GigE c 2ndQuadrant, Ltd. SF PGDAY 2015 15 / 50
University of Manchester
− 4 x Intel Xeon E54620 Eight Core 2.2GHz
Processors, 8 Core/32 Threads
− 256 GB RAM − 10TB storage, 17 x 600GB SSD RAID-0 c 2ndQuadrant, Ltd. SF PGDAY 2015 16 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 17 / 50
− Load Test − Power Test − Throughput Test
c 2ndQuadrant, Ltd. SF PGDAY 2015 18 / 50
Measure the time to load data into 8 tables and build all indexes
c 2ndQuadrant, Ltd. SF PGDAY 2015 19 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 20 / 50
Raw query execution for a single user:
c 2ndQuadrant, Ltd. SF PGDAY 2015 21 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 22 / 50
This query monitors the market response to a promotion such as TV advertisements or a special campaign.
select 100.00 ∗ sum( case when p type like ’PROMO %’ then l extendedprice ∗ (1 − l d i s c o u n t ) else 0 end) / sum( l extendedprice ∗ (1 − l d i s c o u n t ) ) as promo revenue from lineitem , part where l p a r t k e y = p partkey and l shipdate >= date ’1994−10−01 ’ and l shipdate < cast ( date ’1994−10−01 ’ + interval ’1 month ’ as date ) ; c 2ndQuadrant, Ltd. SF PGDAY 2015 23 / 50
This query determines whether selecting less expensive modes of shipping is negatively affecting the critical-priority orders by causing more parts to be received by customers after the committed date.
select l shipmode , sum( case when o o r d e r p r i o r i t y = ’1 − URGENT ’
’2 −HIGH ’ then 1 else 0 end) as high line count , sum( case when o o r d e r p r i o r i t y < > ’1 − URGENT ’ and o o r d e r p r i o r i t y < > ’2 −HIGH ’ then 1 else 0 end) as low line count from orders , l i n e i t e m where o orderkey = l orderkey and l shipmode in ( ’FOB ’ , ’TRUCK ’ ) and l commitdate < l r e c e i p t d a t e and l shipdate < l commitdate and l r e c e i p t d a t e >= date ’1994−01−01 ’ and l r e c e i p t d a t e < date ’1994−01−01 ’ + interval ’1 year ’ group by l shipmode
c 2ndQuadrant, Ltd. SF PGDAY 2015 24 / 50
Measure the system’s ability to execute queries from multiple users simultaneously:
c 2ndQuadrant, Ltd. SF PGDAY 2015 25 / 50
But first design microbenchmarks around BRIN in case their use is masked in the TPC-H workload:
c 2ndQuadrant, Ltd. SF PGDAY 2015 26 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 27 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 28 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 29 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 30 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 31 / 50
BRIN index increases load time by 10% vs 84% B-tree index
c 2ndQuadrant, Ltd. SF PGDAY 2015 32 / 50
Creating a BRIN index is 81% faster than creating a B-tree index
c 2ndQuadrant, Ltd. SF PGDAY 2015 33 / 50
BRIN overhead a constant 10% vs B-tree
c 2ndQuadrant, Ltd. SF PGDAY 2015 34 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 35 / 50
− 28 B-tree indexes across 8 tables − Total build time 46 minutes
− 29 total indexes across 8 tables
− Total build time 34 minutes
c 2ndQuadrant, Ltd. SF PGDAY 2015 36 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 37 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 38 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 39 / 50
− Overall score 2145 (B-tree) vs 1806 (BRIN) − Use of BRIN indexes within 15% of the B-tree
score
− Overall score 1418 (B-tree) vs 1815 (BRIN) − Use of BRIN indexes improves score by 28% c 2ndQuadrant, Ltd. SF PGDAY 2015 40 / 50
5statement timeout set to 3000 seconds for no indexes
c 2ndQuadrant, Ltd. SF PGDAY 2015 41 / 50
− Overall score 10616 (no indexes) vs 1815 BRIN − Use of BRIN indexes improves score by over
71%
6Should be lower without statement timeout set
c 2ndQuadrant, Ltd. SF PGDAY 2015 42 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 43 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 44 / 50
Additional patches 20% improved over 9.2, 14%
c 2ndQuadrant, Ltd. SF PGDAY 2015 45 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 46 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 47 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 48 / 50
c 2ndQuadrant, Ltd. SF PGDAY 2015 49 / 50
The research leading to these results has received funding from the European Union’s Seventh Framework Programme (FP7/2007-2013) under grant agreement n◦ 318633
c 2ndQuadrant, Ltd. SF PGDAY 2015 50 / 50