@@ -48,7 +48,7 @@ Oracle主要通过几个方面来提升它在这个级别的性能:
4848### 单机OLTP性能如何? TPC-C
4949tpc-c是OLTP的工业测试标准之一,商业数据库,硬件厂商大都会用TPC-C的测试结果来彰显自己的性能。
5050
51- PostgreSQL TPC-C在单机的一组测试数据(warehouses=3000, terminals=256)。
51+ PostgreSQL TPC-C在单机的一组测试数据(warehouses=3000, terminals=256)如下,(这组测试数据是机器上有其他混合应用时的测试数据,还有较大的提升空间,到120万tpmC应该没有问题。)。
5252
5353[ 《数据库界的华山论剑 tpc.org》] ( ../201701/20170125_01.md )
5454
@@ -278,7 +278,7 @@ postgres=# explain (analyze,verbose,timing,costs,buffers) select sum(c_custkey),
278278Time: 9709.400 ms (00:09.709)
279279```
280280
281- 提升了N倍性能 。
281+ PG 10采样向量化插件提升了N倍性能,叠加并行化,甚至可以超过DP的性能 。
282282
283283使用向量化除了性能本身的提升,还可以更好的压缩数据。
284284
@@ -300,7 +300,92 @@ postgres=# \dt+ vops_customer
300300(1 row)
301301```
302302
303- [ VOPS guide] ( 20170703_01_vops.html )
303+ 并行叠加向量计算的效果测试。
304+
305+ PG 10: 439毫秒。
306+
307+ ```
308+ postgres=# set max_parallel_workers_per_gather =48;
309+ SET
310+ postgres=# alter table vops_customer set (parallel_workers =48);
311+ ALTER TABLE
312+
313+ postgres=# explain (analyze,verbose,timing,costs,buffers) select sum(c_custkey),avg(c_custkey),min(c_custkey),max(c_custkey),sum(c_nationkey),avg(c_nationkey),min(c_nationkey),max(c_nationkey),sum(c_acctbal),min(c_acctbal),max(c_acctbal),avg(c_acctbal),countall(*) from vops_customer;
314+ Finalize Aggregate (cost=470827.14..470827.15 rows=1 width=104) (actual time=315.794..315.794 rows=1 loops=1)
315+ Output: sum(c_custkey), avg(c_custkey), min(c_custkey), max(c_custkey), sum(c_nationkey), avg(c_nationkey), min(c_nationkey), max(c_nationkey), sum(c_acctbal), min(c_acctbal), max(c_acctbal), avg(c_acctbal), countall(*)
316+ Buffers: shared hit=476862
317+ -> Gather (cost=470825.20..470825.21 rows=48 width=176) (actual time=315.483..315.770 rows=49 loops=1)
318+ Output: (PARTIAL sum(c_custkey)), (PARTIAL avg(c_custkey)), (PARTIAL min(c_custkey)), (PARTIAL max(c_custkey)), (PARTIAL sum(c_nationkey)), (PARTIAL avg(c_nationkey)), (PARTIAL min(c_nationkey)), (PARTIAL max(c_nationkey)), (PAR
319+ TIAL sum(c_acctbal)), (PARTIAL min(c_acctbal)), (PARTIAL max(c_acctbal)), (PARTIAL avg(c_acctbal)), (PARTIAL countall(*))
320+ Workers Planned: 48
321+ Workers Launched: 48
322+ Buffers: shared hit=476862
323+ -> Partial Aggregate (cost=470825.20..470825.21 rows=1 width=176) (actual time=300.421..300.421 rows=1 loops=49)
324+ Output: PARTIAL sum(c_custkey), PARTIAL avg(c_custkey), PARTIAL min(c_custkey), PARTIAL max(c_custkey), PARTIAL sum(c_nationkey), PARTIAL avg(c_nationkey), PARTIAL min(c_nationkey), PARTIAL max(c_nationkey), PARTIAL sum(c_
325+ acctbal), PARTIAL min(c_acctbal), PARTIAL max(c_acctbal), PARTIAL avg(c_acctbal), PARTIAL countall(*)
326+ Buffers: shared hit=468750
327+ Worker 0: actual time=286.534..286.534 rows=1 loops=1
328+ Buffers: shared hit=8616
329+ ......
330+ Worker 46: actual time=310.345..310.345 rows=1 loops=1
331+ Buffers: shared hit=9389
332+ Worker 47: actual time=310.727..310.727 rows=1 loops=1
333+ Buffers: shared hit=9280
334+ ......
335+ -> Parallel Seq Scan on public.vops_customer (cost=0.00..469238.28 rows=48828 width=1584) (actual time=0.017..114.654 rows=47832 loops=49)
336+ Output: c_custkey, c_nationkey, c_acctbal
337+ Buffers: shared hit=468750
338+ Worker 0: actual time=0.021..107.447 rows=43080 loops=1
339+ Buffers: shared hit=8616
340+ Worker 1: actual time=0.019..109.747 rows=42325 loops=1
341+ ......
342+ Worker 47: actual time=0.018..119.142 rows=46400 loops=1
343+ Buffers: shared hit=9280
344+ Planning time: 0.135 ms
345+ Execution time: 439.027 ms
346+ (208 rows)
347+ ```
348+
349+ 相对应的deepgreen测试如下: 532毫秒.
350+
351+ ```
352+ postgres=# select sum(c_custkey),avg(c_custkey),min(c_custkey),max(c_custkey),sum(c_nationkey),avg(c_nationkey),min(c_nationkey),max(c_nationkey),sum(c_acctbal),min(c_acctbal),max(c_acctbal),avg(c_acctbal),count(*) from customer;
353+ sum | avg | min | max | sum | avg | min | max | sum | min | max | avg | count
354+ -------------------+------------+-----+-----------+------------+------------------+-----+-----+------------------+---------+---------+------------------+-----------
355+ 11250000075000000 | 75000000.5 | 1 | 150000000 | 1800117761 | 12.0007850733333 | 0 | 24 | 675048124068.057 | -999.99 | 9999.99 | 4500.32082712038 | 150000000
356+ (1 row)
357+
358+ Time: 531.973 ms
359+
360+ postgres=# explain analyze select sum(c_custkey),avg(c_custkey),min(c_custkey),max(c_custkey),sum(c_nationkey),avg(c_nationkey),min(c_nationkey),max(c_nationkey),sum(c_acctbal),min(c_acctbal),max(c_acctbal),avg(c_acctbal),count(*) from customer;
361+ QUERY PLAN
362+ ---------------------------------------------------------------------------------------------------------------------------------------------
363+ Aggregate (cost=7151025.61..7151025.62 rows=1 width=200)
364+ Rows out: 1 rows with 0.001 ms to first row, 330 ms to end, start offset by 1.624 ms.
365+ -> Gather Motion 48:1 (slice1; segments: 48) (cost=7151025.03..7151025.53 rows=1 width=224)
366+ Rows out: 48 rows at destination with 458 ms to end, start offset by 1.625 ms.
367+ -> Aggregate (cost=7151025.03..7151025.04 rows=1 width=224)
368+ Rows out: Avg 1.0 rows x 48 workers. Max 1 rows (seg0) with 0.002 ms to first row, 471 ms to end, start offset by 4.299 ms.
369+ -> Append-only Columnar Scan on customer (cost=0.00..2276025.00 rows=3125000 width=24)
370+ Rows out: 0 rows (seg0) with 57 ms to end, start offset by 71 ms.
371+ Slice statistics:
372+ (slice0) Executor memory: 443K bytes.
373+ (slice1) Executor memory: 18722K bytes avg x 48 workers, 18722K bytes max (seg0).
374+ Statement statistics:
375+ Memory used: 128000K bytes
376+ Settings: optimizer=off
377+ Optimizer status: legacy query optimizer
378+ Total runtime: 789.744 ms
379+ (16 rows)
380+
381+ Time: 791.114 ms
382+ ```
383+
384+ ![ pic] ( 20170703_01_pic_007.jpg )
385+
386+ PG 10 多核+向量计算组合后,已和Deepgreen的分析性能持平甚至略好。(要知道测试中,PG10 还没有使用正儿八经的列式存储呢,还有提升的潜力。)
387+
388+ [ PostgreSQL VOPS guide] ( 20170703_01_vops.html )
304389
305390#### 3、多核并行
306391
0 commit comments