天天看点

PostgreSQL 9.5.0 PK Oracle 12.0.1.2.0 TPC-C性能极限

oracle 12c tpc-c 测试请参考:

http://blog.163.com/digoal@126/blog/static/1638770402015112344924835/

文件系统为xfs,优化手段如下:

http://blog.163.com/digoal@126/blog/static/16387704020160695427218/

本文在同样的硬件测试环境下对比postgresql 9.5.0。

我们看看1月7号发布的postgresql 新版本性能咋样?

benchmarksql 配置请参考:

编译器版本

gcc version 4.4.6 20110731 (red hat 4.4.6-3) (gcc) 

postgresql编译项

./configure --prefix=/u02/digoal/soft_bak/pgsql9.5 --with-blocksize=8 --with-pgport=1921 --with-perl --with-python --with-tcl --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --enable-thread-safety

gmake world -j32

gmake install-world -j32

配置postgres环境变量

$ vi env_pg.sh 

export ps1="$user@`/bin/hostname -s`-> "

export pgport=1921

export pgdata=/data01/pgdata/pg_root

export lang=en_us.utf8

export pghome=/u02/digoal/soft_bak/pgsql9.5

export ld_library_path=$pghome/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$ld_library_path

export date=`date +"%y%m%d%h%m"`

export path=$pghome/bin:$path:.

export manpath=$pghome/share/man:$manpath

export pghost=$pgdata

export pgdatabase=postgres

export pguser=postgres

alias rm='rm -i'

alias ll='ls -lh'

unalias vi

配置postgresql.conf

$ vi $pgdata/postgresql.conf

port = 1921                             # (change requires restart)

max_connections = 300                   # (change requires restart)

unix_socket_directories = '.'   # comma-separated list of directories

shared_buffers = 32gb                   # min 128kb

huge_pages = try                       # on, off, or try

maintenance_work_mem = 2gb              # min 1mb

dynamic_shared_memory_type = posix      # the default is the first option

bgwriter_delay = 10ms                   # 10-10000ms between rounds

wal_level = minimal  # minimal, archive, hot_standby, or logical

synchronous_commit = off                # synchronization level;

full_page_writes = off                  # recover from partial page writes

wal_buffers = 16mb                       # min 32kb, -1 sets based on shared_buffers

wal_writer_delay = 10ms         # 1-10000 milliseconds

max_wal_size = 32gb

effective_cache_size = 240gb

log_destination = 'csvlog'              # valid values are combinations of

logging_collector = on          # enable capturing of stderr and csvlog

log_truncate_on_rotation = on           # if on, an existing log file with the

log_timezone = 'prc'

datestyle = 'iso, mdy'

timezone = 'prc'

lc_messages = 'c'                       # locale for system error message

lc_monetary = 'c'                       # locale for monetary formatting

lc_numeric = 'c'                        # locale for number formatting

lc_time = 'c'                           # locale for time formatting

default_text_search_config = 'pg_catalog.english'

下载最新java版本对应的postgresql jdbc jar

wget https://jdbc.postgresql.org/download/postgresql-9.4.1207.jre7.jar

mv postgresql-9.4.1207.jre7.jar benchmarksql-4.1.0/lib/

配置benchmarksql,使用新的postgresql java驱动

$ vi runbenchmark.sh 

java -cp .:../lib/postgresql-9.4.1207.jre7.jar:../lib/log4j-1.2.17.jar:../lib/apache-log4j-extras-1.1.jar:../dist/benchmarksql-4.1.jar -dprop=$1 jtpcc

$ vi runloader.sh

java -cp .:../lib/postgresql-9.4.1207.jre7.jar:../dist/benchmarksql-4.1.jar -dprop=$1 loaddata $2 $3 $4 $5

$ vi runsql.sh 

mycp="../lib/postgresql-9.4.1207.jre7.jar"

mycp="$mycp:../dist/benchmarksql-4.1.jar"

myopts="-dprop=$1"

myopts="$myopts -dcommandfile=$2"

java -cp .:$mycp $myopts execjdbc

修改log4j,减少日志打印量。priority改成info,只输出最终结果,不输出产生订单的日志。

$ vi log4j.xml

<?xml version="1.0" encoding="utf-8" ?>

<!doctype log4j:configuration system "log4j.dtd">

<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>

<appender name="console" class="org.apache.log4j.consoleappender">

<param name="threshold" value="info"/>

<layout class="org.apache.log4j.patternlayout">

<param name="conversionpattern" value="%d %5p - %m%n"/>

</layout>

</appender>

<appender name="r" class="org.apache.log4j.rolling.rollingfileappender">

<param name="append" value="true" />

<rollingpolicy class="org.apache.log4j.rolling.timebasedrollingpolicy">

<param name="filenamepattern" value="log/archive/benchmarksql.%d{yyyymmddhhmm}.log"/>

<param name="activefilename" value="log/benchmarksql.log"/>

</rollingpolicy>

<triggeringpolicy class="org.apache.log4j.rolling.sizebasedtriggeringpolicy">

<param name="maxfilesize" value="1"/>

</triggeringpolicy>

<param name="conversionpattern" value="%5p\t[%d{yyyy-mm-dd hh:mm:ss.sss}]\t%t \t%m%n"/>

<filter class="org.apache.log4j.filter.stringmatchfilter">

<param name="stringtomatch" value ="\n" />

<param name="acceptonmatch" value="false" />

</filter>

<appender name="e" class="org.apache.log4j.rolling.rollingfileappender">

<param name="threshold" value="warn"/>

<param name="filenamepattern" value="log/benchmarksqlerror.%d.log"/>

<param name="activefilename" value="log/benchmarksqlerror.log"/>

<root>

<priority value="info"/>

<appender-ref ref="r"/>

<appender-ref ref="e"/>

</root>

</log4j:configuration>

编辑连接配置和压测配置,与测试oracle 12c 的保持一致。

1000 个仓库,约5亿数据量。

$ vi props.pg 

driver=org.postgresql.driver

conn=jdbc:postgresql://localhost:1921/postgres

user=postgres

password=123

warehouses=1000

terminals=96

//to run specified transactions per terminal- runmins must equal zero

runtxnsperterminal=0

//to run for specified minutes- runtxnsperterminal must equal zero

runmins=1

//number of total transactions per minute

limittxnspermin=0

//the following five values must add up to 100

//the default percentages of 45, 43, 4, 4 & 4 match the tpc-c spec

neworderweight=40

paymentweight=36

orderstatusweight=8

deliveryweight=8

stocklevelweight=8

配置postgres用户默认搜索路径

$ psql

psql (9.5.0)

type "help" for help.

postgres=# alter role postgres set search_path='benchmarksql','public';

创建用于存放生成csv的目录

$ mkdir /u02/digoal/soft_bak/benchcsv

修改sqltablecopies,指定目录

$ vi sqltablecopies 

copy benchmarksql.warehouse

  (w_id, w_ytd, w_tax, w_name, w_street_1, w_street_2, w_city, w_state, w_zip)  

  from '/u02/digoal/soft_bak/benchcsv/warehouse.csv' with csv;

copy benchmarksql.item

  (i_id, i_name, i_price, i_data, i_im_id) 

  from '/u02/digoal/soft_bak/benchcsv/item.csv' with csv;

copy benchmarksql.stock

  (s_i_id, s_w_id, s_quantity, s_ytd, s_order_cnt, s_remote_cnt, s_data,

   s_dist_01, s_dist_02, s_dist_03, s_dist_04, s_dist_05,

   s_dist_06, s_dist_07, s_dist_08, s_dist_09, s_dist_10)

  from '/u02/digoal/soft_bak/benchcsv/stock.csv' with csv;

copy benchmarksql.district

  (d_id, d_w_id, d_ytd, d_tax, d_next_o_id, d_name, d_street_1,

   d_street_2, d_city, d_state, d_zip) 

  from '/u02/digoal/soft_bak/benchcsv/district.csv' with csv;

copy benchmarksql.customer

  (c_id, c_d_id, c_w_id, c_discount, c_credit, c_last, c_first, c_credit_lim, 

   c_balance, c_ytd_payment, c_payment_cnt, c_delivery_cnt, c_street_1, 

   c_street_2, c_city, c_state, c_zip, c_phone, c_since, c_middle, c_data) 

  from '/u02/digoal/soft_bak/benchcsv/customer.csv' with csv;

copy benchmarksql.history

  (hist_id, h_c_id, h_c_d_id, h_c_w_id, h_d_id, h_w_id, h_date, h_amount, h_data) 

  from '/u02/digoal/soft_bak/benchcsv/cust-hist.csv' with csv;

copy benchmarksql.oorder

  (o_id, o_w_id, o_d_id, o_c_id, o_carrier_id, o_ol_cnt, o_all_local, o_entry_d) 

  from '/u02/digoal/soft_bak/benchcsv/order.csv' with csv;

copy benchmarksql.order_line

  (ol_w_id, ol_d_id, ol_o_id, ol_number, ol_i_id, ol_delivery_d, 

   ol_amount, ol_supply_w_id, ol_quantity, ol_dist_info) 

  from '/u02/digoal/soft_bak/benchcsv/order-line.csv' with csv;

copy benchmarksql.new_order

  (no_w_id, no_d_id, no_o_id)  

  from '/u02/digoal/soft_bak/benchcsv/new-order.csv' with csv;

建立表结构

$ cd benchmarksql-4.1.0/run

$ ./runsql.sh props.pg sqltablecreates

生成csv

$ ./runloader.sh props.pg numwarehouses 1000 filelocation /u02/digoal/soft_bak/benchcsv/ 

1000个仓库的数据量:

total 69g

-rw-r--r-- 1 digoal users 2.0g jan  9 15:53 cust-hist.csv

-rw-r--r-- 1 digoal users  16g jan  9 15:53 customer.csv

-rw-r--r-- 1 digoal users 898k jan  9 15:12 district.csv

-rw-r--r-- 1 digoal users 7.0m jan  9 14:22 item.csv

-rw-r--r-- 1 digoal users  95m jan  9 16:14 new-order.csv

-rw-r--r-- 1 digoal users 1.3g jan  9 16:14 order.csv

-rw-r--r-- 1 digoal users  22g jan  9 16:14 order-line.csv

-rw-r--r-- 1 digoal users  28g jan  9 15:12 stock.csv

-rw-r--r-- 1 digoal users  84k jan  9 14:22 warehouse.csv

导入数据库

$ ./runsql.sh props.pg sqltablecopies

创建约束和索引

$ ./runsql.sh props.pg sqlindexcreates 

备份

$ pg_dump -f /u02/digoal/soft_bak/benchmarksql.dmp -f c -n benchmarksql postgres

压测:

nohup ./runbenchmark.sh props.pg >/dev/null 2>./errrun.log &

测试结果:

 info   [2016-01-09 22:03:39.961]       thread-7        term-00, 

 info   [2016-01-09 22:03:39.963]       thread-7        term-00, 

 info   [2016-01-09 22:03:39.963]       thread-7        term-00, measured tpmc (neworders) = 102494.46

 info   [2016-01-09 22:03:39.963]       thread-7        term-00, measured tpmtotal = 256195.32

 info   [2016-01-09 22:03:39.964]       thread-7        term-00, session start     = 2016-01-09 21:53:39

 info   [2016-01-09 22:03:39.964]       thread-7        term-00, session end       = 2016-01-09 22:03:39

 info   [2016-01-09 22:03:39.964]       thread-7        term-00, transaction count = 2563088

主机信息,截取压测第9分钟的数据。

top

top - 22:02:09 up 3 days, 12:55,  3 users,  load average: 19.23, 15.97, 8.37

tasks: 619 total,  10 running, 609 sleeping,   0 stopped,   0 zombie

cpu(s): 35.0%us,  9.4%sy,  0.0%ni, 52.6%id,  0.1%wa,  0.0%hi,  2.9%si,  0.0%st

mem:  264643396k total, 241719372k used, 22924024k free,    36672k buffers

swap: 18825200k total,        0k used, 18825200k free, 196557376k cached

iostat -x

avg-cpu:  %user   %nice %system %iowait  %steal   %idle

          35.07    0.00   12.30    0.12    0.00   52.51

device:         rrqm/s   wrqm/s     r/s     w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util

dfa               0.00     0.00   57.40  743.40   918.40 11849.00    15.94     0.02    0.03   0.03   2.08

dfb               0.00     0.00   57.20  740.40   915.20 11829.00    15.98     0.02    0.03   0.03   2.04

dfc               0.00     0.00   58.40  730.80   934.40 11675.80    15.98     0.03    0.03   0.03   2.52

dm-0              0.00     0.00  173.00 2213.20  2768.00 35331.40    15.97     0.08    0.03   0.03   7.02

oracle有awr报告,postgresql可以使用oprofile跟踪统计:

参考

http://blog.163.com/digoal@126/blog/static/163877040201549115140794/

找到需要优化的代码就靠它了。

cpu: intel ivy bridge microarchitecture, speed 2600 mhz (estimated)

counted cpu_clk_unhalted events (clock cycles when not halted) with a unit mask of 0x00 (no unit mask) count 100000

vma      samples  %        app name                 symbol name

007a7780 751274    5.1565  /soft/digoal/soft_bak/pgsql9.5/bin/postgres hash_search_with_hash_value

004a92f0 574315    3.9419  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_compare

006a4bd0 514473    3.5312  /soft/digoal/soft_bak/pgsql9.5/bin/postgres lwlockacquire

0078a090 510962    3.5071  /soft/digoal/soft_bak/pgsql9.5/bin/postgres searchcatcache

007bc3a0 484601    3.3262  /soft/digoal/soft_bak/pgsql9.5/bin/postgres allocsetalloc

006969c0 442341    3.0361  /soft/digoal/soft_bak/pgsql9.5/bin/postgres getsnapshotdata

00498930 352134    2.4170  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heap_hot_search_buffer

005b8f70 279718    1.9199  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execinitexpr

006895d0 249377    1.7117  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pinbuffer

006a4220 168770    1.1584  /soft/digoal/soft_bak/pgsql9.5/bin/postgres lwlockrelease

007ac620 161861    1.1110  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pg_encoding_mbcliplen

007a2180 161090    1.1057  /soft/digoal/soft_bak/pgsql9.5/bin/postgres functioncall2coll

004aaa80 153079    1.0507  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_checkkeys

007a3950 147078    1.0095  /soft/digoal/soft_bak/pgsql9.5/bin/postgres fmgr_info_cxt_security

0049bce0 136680    0.9381  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heap_page_prune_opt

0048c8f0 130807    0.8978  /soft/digoal/soft_bak/pgsql9.5/bin/postgres hash_any

006b2e50 130564    0.8962  /soft/digoal/soft_bak/pgsql9.5/bin/postgres postgresmain

0046c790 121776    0.8358  /soft/digoal/soft_bak/pgsql9.5/bin/postgres slot_deform_tuple

007bd0f0 114514    0.7860  /soft/digoal/soft_bak/pgsql9.5/bin/postgres palloc

007bd210 103245    0.7086  /soft/digoal/soft_bak/pgsql9.5/bin/postgres memorycontextalloczeroaligned

006b14a0 99669     0.6841  /soft/digoal/soft_bak/pgsql9.5/bin/postgres exec_bind_message

0049b300 94389     0.6479  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heap_page_prune

007bce00 87034     0.5974  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pfree

00494ba0 83545     0.5734  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heap_update

0046c580 79535     0.5459  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heap_getsysattr

005ef6e0 79099     0.5429  /soft/digoal/soft_bak/pgsql9.5/bin/postgres expression_tree_walker

007bca10 71379     0.4899  /soft/digoal/soft_bak/pgsql9.5/bin/postgres allocsetfree

0068b1b0 66956     0.4596  /soft/digoal/soft_bak/pgsql9.5/bin/postgres readbuffer_common

007cb070 66438     0.4560  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heaptuplesatisfiesmvcc

00471e30 66340     0.4553  /soft/digoal/soft_bak/pgsql9.5/bin/postgres tupledescinitentry

004a9630 61952     0.4252  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_moveright

006a0770 61336     0.4210  /soft/digoal/soft_bak/pgsql9.5/bin/postgres lockacquireextended

005b8530 60524     0.4154  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execproject

004a9950 58783     0.4035  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_first

00788880 57798     0.3967  /soft/digoal/soft_bak/pgsql9.5/bin/postgres catalogcachecomputehashvalue

004a9510 56865     0.3903  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_binsrch

004a52b0 56152     0.3854  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_checkpage

005f2270 54679     0.3753  /soft/digoal/soft_bak/pgsql9.5/bin/postgres lappend

005c9ba0 53697     0.3686  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execindexbuildscankeys

00689cb0 53634     0.3681  /soft/digoal/soft_bak/pgsql9.5/bin/postgres unpinbuffer.clone.0

007bc980 53151     0.3648  /soft/digoal/soft_bak/pgsql9.5/bin/postgres allocsetreset

005beaa0 52618     0.3612  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execscan

007a7dc0 51582     0.3540  /soft/digoal/soft_bak/pgsql9.5/bin/postgres hash_search

007a2900 51152     0.3511  /soft/digoal/soft_bak/pgsql9.5/bin/postgres directfunctioncall1coll

004ab240 50878     0.3492  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_preprocess_keys

005dfd60 50583     0.3472  /soft/digoal/soft_bak/pgsql9.5/bin/postgres appendbinarystringinfo

005e9cc0 50034     0.3434  /soft/digoal/soft_bak/pgsql9.5/bin/postgres internal_putbytes

005bc6e0 49198     0.3377  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execmakefunctionresultnosets

004a1dc0 49038     0.3366  /soft/digoal/soft_bak/pgsql9.5/bin/postgres index_getnext_tid

004a8a20 48143     0.3304  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_readpage

0064a240 47657     0.3271  /soft/digoal/soft_bak/pgsql9.5/bin/postgres waitlatchorsocket

0079ea80 47439     0.3256  /soft/digoal/soft_bak/pgsql9.5/bin/postgres errstart

005e9d60 47317     0.3248  /soft/digoal/soft_bak/pgsql9.5/bin/postgres socket_putmessage

0048cbb0 47011     0.3227  /soft/digoal/soft_bak/pgsql9.5/bin/postgres hash_uint32

005f4620 46989     0.3225  /soft/digoal/soft_bak/pgsql9.5/bin/postgres copyobject

006b0200 46725     0.3207  /soft/digoal/soft_bak/pgsql9.5/bin/postgres check_stack_depth

004d98b0 46404     0.3185  /soft/digoal/soft_bak/pgsql9.5/bin/postgres xloginsertrecord

005f14a0 46255     0.3175  /soft/digoal/soft_bak/pgsql9.5/bin/postgres exprtypmod

0078ceb0 46137     0.3167  /soft/digoal/soft_bak/pgsql9.5/bin/postgres acquireexecutorlocks

005c0120 46060     0.3161  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execbuildprojectioninfo

005b7a00 45845     0.3147  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execprocnode

005cba00 45621     0.3131  /soft/digoal/soft_bak/pgsql9.5/bin/postgres indexonlynext

004dcd00 44996     0.3088  /soft/digoal/soft_bak/pgsql9.5/bin/postgres xloginsert

007bd900 43828     0.3008  /soft/digoal/soft_bak/pgsql9.5/bin/postgres memorycontextcreate

005bf590 43739     0.3002  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execcleartuple

00651290 43411     0.2980  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pgstat_report_activity

00688ad0 42177     0.2895  /soft/digoal/soft_bak/pgsql9.5/bin/postgres buffergetblocknumber

005cec40 42120     0.2891  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execinitmodifytable

007add70 41781     0.2868  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pg_utf_mblen

004a1cb0 41096     0.2821  /soft/digoal/soft_bak/pgsql9.5/bin/postgres index_fetch_heap

007bf720 41079     0.2820  /soft/digoal/soft_bak/pgsql9.5/bin/postgres resourceownerreleaseinternal

005b6510 39744     0.2728  /soft/digoal/soft_bak/pgsql9.5/bin/postgres standard_executorstart

00689050 39400     0.2704  /soft/digoal/soft_bak/pgsql9.5/bin/postgres getprivaterefcountentry

0046cc10 39374     0.2703  /soft/digoal/soft_bak/pgsql9.5/bin/postgres slot_getattr

004a8470 39371     0.2702  /soft/digoal/soft_bak/pgsql9.5/bin/postgres btgettuple

0046da10 39200     0.2691  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heap_fill_tuple

005cb000 38886     0.2669  /soft/digoal/soft_bak/pgsql9.5/bin/postgres indexnext

0068bdf0 38798     0.2663  /soft/digoal/soft_bak/pgsql9.5/bin/postgres readbufferextended

0046d1a0 37687     0.2587  /soft/digoal/soft_bak/pgsql9.5/bin/postgres nocachegetattr

00795a70 37478     0.2572  /soft/digoal/soft_bak/pgsql9.5/bin/postgres searchsyscache

005bf220 37089     0.2546  /soft/digoal/soft_bak/pgsql9.5/bin/postgres exectypefromtlinternal

007bce90 36895     0.2532  /soft/digoal/soft_bak/pgsql9.5/bin/postgres memorycontextreset

004ee700 36585     0.2511  /soft/digoal/soft_bak/pgsql9.5/bin/postgres overridesearchpathmatchescurrent

007bd580 36499     0.2505  /soft/digoal/soft_bak/pgsql9.5/bin/postgres palloc0

005b7cc0 35752     0.2454  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execinitnode

005f1170 33509     0.2300  /soft/digoal/soft_bak/pgsql9.5/bin/postgres exprtype

004a9250 33443     0.2295  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_next

007ca070 33169     0.2277  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heaptuplesatisfiesvacuum

006b5e40 32701     0.2245  /soft/digoal/soft_bak/pgsql9.5/bin/postgres portalstart

007d0c90 32526     0.2232  /soft/digoal/soft_bak/pgsql9.5/bin/postgres strlcpy

0078bf60 32247     0.2213  /soft/digoal/soft_bak/pgsql9.5/bin/postgres scanqueryforlocks

0078d190 31821     0.2184  /soft/digoal/soft_bak/pgsql9.5/bin/postgres getcachedplan

004a2510 31799     0.2183  /soft/digoal/soft_bak/pgsql9.5/bin/postgres btint4cmp

00689100 31038     0.2130  /soft/digoal/soft_bak/pgsql9.5/bin/postgres lockbuffer

005cf920 30845     0.2117  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execmodifytable

007d3720 29991     0.2059  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pg_comp_crc32c_sse42

006b5a90 29990     0.2058  /soft/digoal/soft_bak/pgsql9.5/bin/postgres portalrun

00702c10 29945     0.2055  /soft/digoal/soft_bak/pgsql9.5/bin/postgres int4eq

0068bf30 29506     0.2025  /soft/digoal/soft_bak/pgsql9.5/bin/postgres releaseandreadbuffer

0072ca70 29180     0.2003  /soft/digoal/soft_bak/pgsql9.5/bin/postgres oideq

0046f830 28791     0.1976  /soft/digoal/soft_bak/pgsql9.5/bin/postgres printtup

00652500 28686     0.1969  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pgstat_initstats

005b6360 27850     0.1912  /soft/digoal/soft_bak/pgsql9.5/bin/postgres standard_executorrun

004a97d0 27303     0.1874  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_search

005eb820 26910     0.1847  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pq_copymsgbytes

0078c9b0 26717     0.1834  /soft/digoal/soft_bak/pgsql9.5/bin/postgres revalidatecachedquery

0046d7f0 26409     0.1813  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heap_compute_data_size

007bef90 25986     0.1784  /soft/digoal/soft_bak/pgsql9.5/bin/postgres resourceownerforgetcatcacheref

006a4580 25980     0.1783  /soft/digoal/soft_bak/pgsql9.5/bin/postgres lwlockreleaseclearvar

007bf0b0 25691     0.1763  /soft/digoal/soft_bak/pgsql9.5/bin/postgres resourceownerforgetbuffer

007bf510 25517     0.1751  /soft/digoal/soft_bak/pgsql9.5/bin/postgres resourceownerenlargecatcacherefs

007bd2f0 25285     0.1735  /soft/digoal/soft_bak/pgsql9.5/bin/postgres memorycontextalloc

004e3d60 25205     0.1730  /soft/digoal/soft_bak/pgsql9.5/bin/postgres issharedrelation

004992e0 25201     0.1730  /soft/digoal/soft_bak/pgsql9.5/bin/postgres relation_open

004a8ce0 24931     0.1711  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_steppage

007ccf70 24845     0.1705  /soft/digoal/soft_bak/pgsql9.5/bin/postgres gettransactionsnapshot

007bd7f0 24785     0.1701  /soft/digoal/soft_bak/pgsql9.5/bin/postgres memorycontextalloczero

007ba4a0 24592     0.1688  /soft/digoal/soft_bak/pgsql9.5/bin/postgres set_ps_display

007bc920 24354     0.1672  /soft/digoal/soft_bak/pgsql9.5/bin/postgres allocsetdelete

005eff70 24317     0.1669  /soft/digoal/soft_bak/pgsql9.5/bin/postgres exprcollation

005ca790 24152     0.1658  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execinitindexscan

005dfbc0 24115     0.1655  /soft/digoal/soft_bak/pgsql9.5/bin/postgres enlargestringinfo

005ea540 23995     0.1647  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pq_getmessage

0069e680 23983     0.1646  /soft/digoal/soft_bak/pgsql9.5/bin/postgres lockrelease

005eb920 23770     0.1632  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pq_getmsgint

007ace30 23767     0.1631  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pg_client_to_server

004a1980 23709     0.1627  /soft/digoal/soft_bak/pgsql9.5/bin/postgres index_getprocinfo

0078a010 23542     0.1616  /soft/digoal/soft_bak/pgsql9.5/bin/postgres releasecatcache

007ccc80 23300     0.1599  /soft/digoal/soft_bak/pgsql9.5/bin/postgres popactivesnapshot

004cdcb0 22416     0.1539  /soft/digoal/soft_bak/pgsql9.5/bin/postgres recoveryinprogress

007d25c0 22374     0.1536  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pg_qsort

005b5eb0 22083     0.1516  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execcheckrtperms

007a6f50 21858     0.1500  /soft/digoal/soft_bak/pgsql9.5/bin/postgres get_hash_value

006aad10 21263     0.1459  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pageadditem

005b2610 21253     0.1459  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execrescan

004a0b80 19739     0.1355  /soft/digoal/soft_bak/pgsql9.5/bin/postgres visibilitymap_test

0069f270 19567     0.1343  /soft/digoal/soft_bak/pgsql9.5/bin/postgres lockreassignowner

005f1a30 19556     0.1342  /soft/digoal/soft_bak/pgsql9.5/bin/postgres new_list

007663a0 19503     0.1339  /soft/digoal/soft_bak/pgsql9.5/bin/postgres getcurrenttimestamp

005bf8d0 19422     0.1333  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execstoretuple

005b76c0 19322     0.1326  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execendnode

004a71b0 19143     0.1314  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_getroot

006af8e0 19088     0.1310  /soft/digoal/soft_bak/pgsql9.5/bin/postgres forbidden_in_wal_sender

005ebb10 18924     0.1299  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pq_begintypsend

007cc9f0 18916     0.1298  /soft/digoal/soft_bak/pgsql9.5/bin/postgres snapshotresetxmin

005b8df0 18698     0.1283  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execevalparamextern

007bcca0 18595     0.1276  /soft/digoal/soft_bak/pgsql9.5/bin/postgres memorycontextsetparent

005dff50 18305     0.1256  /soft/digoal/soft_bak/pgsql9.5/bin/postgres initstringinfo

0069d6c0 18277     0.1254  /soft/digoal/soft_bak/pgsql9.5/bin/postgres lockrelationoid

007a8640 18167     0.1247  /soft/digoal/soft_bak/pgsql9.5/bin/postgres string_hash

0071e5a0 18155     0.1246  /soft/digoal/soft_bak/pgsql9.5/bin/postgres namestrcpy

007bc6a0 17961     0.1233  /soft/digoal/soft_bak/pgsql9.5/bin/postgres allocsetcontextcreate

0063bfe0 17393     0.1194  /soft/digoal/soft_bak/pgsql9.5/bin/postgres get_leftop

005ea810 17343     0.1190  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pq_getbyte

005cea20 17261     0.1185  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execcheckplanoutput

004d44d0 17143     0.1177  /soft/digoal/soft_bak/pgsql9.5/bin/postgres getxlogbuffer

005b8460 17054     0.1171  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execqual

004a2030 16718     0.1147  /soft/digoal/soft_bak/pgsql9.5/bin/postgres index_endscan

004ab9b0 16717     0.1147  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_preprocess_array_keys

00472530 16616     0.1140  /soft/digoal/soft_bak/pgsql9.5/bin/postgres createtemplatetupledesc

006b54f0 16267     0.1117  /soft/digoal/soft_bak/pgsql9.5/bin/postgres portalrunmulti

004c3bf0 16212     0.1113  /soft/digoal/soft_bak/pgsql9.5/bin/postgres transactionidprecedes

006aa500 16187     0.1111  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pagerepairfragmentation

00797910 16150     0.1108  /soft/digoal/soft_bak/pgsql9.5/bin/postgres gettypebinaryinputinfo

007bea30 16076     0.1103  /soft/digoal/soft_bak/pgsql9.5/bin/postgres resourceownerremembercatcacheref

007af080 16065     0.1103  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pg_verify_mbstr_len

0078c930 16016     0.1099  /soft/digoal/soft_bak/pgsql9.5/bin/postgres releasecachedplan

005da020 15979     0.1097  /soft/digoal/soft_bak/pgsql9.5/bin/postgres spi_push_conditional

007caf50 15901     0.1091  /soft/digoal/soft_bak/pgsql9.5/bin/postgres xidinmvccsnapshot

005bf9f0 15865     0.1089  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execsetslotdescriptor

00793590 15814     0.1085  /soft/digoal/soft_bak/pgsql9.5/bin/postgres relationincrementreferencecount

005be970 15643     0.1074  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execassignscanprojectioninfowithvarno

0057f9f0 15487     0.1063  /soft/digoal/soft_bak/pgsql9.5/bin/postgres portalcleanup

0049a880 15356     0.1054  /soft/digoal/soft_bak/pgsql9.5/bin/postgres relationgetbufferfortuple

007baf90 15353     0.1054  /soft/digoal/soft_bak/pgsql9.5/bin/postgres superuser_arg

005e15c0 15223     0.1045  /soft/digoal/soft_bak/pgsql9.5/bin/postgres secure_read

0069f3e0 15065     0.1034  /soft/digoal/soft_bak/pgsql9.5/bin/postgres grantlocklocal

005ea4c0 15027     0.1031  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pq_getbytes

005efe10 14951     0.1026  /soft/digoal/soft_bak/pgsql9.5/bin/postgres expression_returns_set_walker

006b2c60 14765     0.1013  /soft/digoal/soft_bak/pgsql9.5/bin/postgres processclientreadinterrupt

006a0280 14639     0.1005  /soft/digoal/soft_bak/pgsql9.5/bin/postgres lockreleaseall

004cb500 14633     0.1004  /soft/digoal/soft_bak/pgsql9.5/bin/postgres committransactioncommand

0049af30 14626     0.1004  /soft/digoal/soft_bak/pgsql9.5/bin/postgres relationputheaptuple

007bee50 14621     0.1004  /soft/digoal/soft_bak/pgsql9.5/bin/postgres resourceownerforgetrelationref

006cc090 14602     0.1002  /soft/digoal/soft_bak/pgsql9.5/bin/postgres deconstruct_array

阶段1(测试程序和数据库在同一主机)postgresql 9.5.0 对比 oracle 12c tpc-c tpm对比如下:

PostgreSQL 9.5.0 PK Oracle 12.0.1.2.0 TPC-C性能极限

测试数据仅供参考。

使用benchmarksql测试,系统还有大量空闲cpu,io资源,所以性能应该不止于此。预计postgresql可到50w tpm。

有兴趣的童鞋可以使用load runner或者sysbench或其他工具再测试一下。

------------------------------------------------------------------------------------------------------------

特别感谢给oracle优化支招的oracle圈子的兄弟姐妹们。

优化中,期待oracle更好的表现。

awr报告截图见:

<b>阶段2对比,</b>

benchmarksql放到另一台主机,主机间万兆网同一交换机下互联。

http://blog.163.com/digoal@126/blog/static/163877040201601021838221/

为了突破测试程序的极限,开4个schema,每个schema负责1000个仓库,数据量总共20亿左右,数据量400gb。

每个测试程序对付一个schema。

终端数保持一致,每个测试程序开24个终端,一共96个终端。

测试数据量

postgres=# \l+

                                                               list of databases

   name    |  owner   | encoding | collate | ctype |   access privileges   |  size   | tablespace |                description                 

-----------+----------+----------+---------+-------+-----------------------+---------+------------+--------------------------------------------

 test01    | test01   | utf8     | c       | c     |                       | 100 gb  | pg_default | 

 test02    | test02   | utf8     | c       | c     |                       | 100 gb  | pg_default | 

 test03    | test03   | utf8     | c       | c     |                       | 100 gb  | pg_default | 

 test04    | test04   | utf8     | c       | c     |                       | 100 gb  | pg_default | 

benchmarksql软件目录

$ ll

drwxr-xr-x 7 digoal users 4.0k jan 10 14:41 benchmarksql-4.1.0_pg01

drwxr-xr-x 7 digoal users 4.0k jan 10 14:41 benchmarksql-4.1.0_pg02

drwxr-xr-x 7 digoal users 4.0k jan 10 14:41 benchmarksql-4.1.0_pg03

drwxr-xr-x 7 digoal users 4.0k jan 10 14:41 benchmarksql-4.1.0_pg04

测试

cd benchmarksql-4.1.0_pg01/run

cd ../../benchmarksql-4.1.0_pg02/run

cd ../../benchmarksql-4.1.0_pg03/run

cd ../../benchmarksql-4.1.0_pg04/run

cd ../..

测试结果

$ cat benchmarksql-4.1.0_pg01/run/log/benchmarksql.log 

 info   [2016-01-10 17:54:04.925]       thread-22       term-00, measured tpmc (neworders) = 45416.28

 info   [2016-01-10 17:54:04.925]       thread-22       term-00, measured tpmtotal = 113487.61

 info   [2016-01-10 17:54:04.925]       thread-22       term-00, session start     = 2016-01-10 17:44:04

 info   [2016-01-10 17:54:04.925]       thread-22       term-00, session end       = 2016-01-10 17:54:04

 info   [2016-01-10 17:54:04.925]       thread-22       term-00, transaction count = 1134913

$ cat benchmarksql-4.1.0_pg02/run/log/benchmarksql.log 

 info   [2016-01-10 17:54:04.943]       thread-12       term-00, measured tpmc (neworders) = 45292.48

 info   [2016-01-10 17:54:04.943]       thread-12       term-00, measured tpmtotal = 113269.54

 info   [2016-01-10 17:54:04.943]       thread-12       term-00, session start     = 2016-01-10 17:44:04

 info   [2016-01-10 17:54:04.944]       thread-12       term-00, session end       = 2016-01-10 17:54:04

 info   [2016-01-10 17:54:04.944]       thread-12       term-00, transaction count = 1132770

$ cat benchmarksql-4.1.0_pg03/run/log/benchmarksql.log 

 info   [2016-01-10 17:54:04.955]       thread-12       term-00, measured tpmc (neworders) = 45336.15

 info   [2016-01-10 17:54:04.955]       thread-12       term-00, measured tpmtotal = 113247.19

 info   [2016-01-10 17:54:04.956]       thread-12       term-00, session start     = 2016-01-10 17:44:04

 info   [2016-01-10 17:54:04.956]       thread-12       term-00, session end       = 2016-01-10 17:54:04

 info   [2016-01-10 17:54:04.956]       thread-12       term-00, transaction count = 1132537

$ cat benchmarksql-4.1.0_pg04/run/log/benchmarksql.log 

 info   [2016-01-10 17:54:04.986]       thread-23       term-00, measured tpmc (neworders) = 45231.67

 info   [2016-01-10 17:54:04.987]       thread-23       term-00, measured tpmtotal = 113054.3

 info   [2016-01-10 17:54:04.987]       thread-23       term-00, session start     = 2016-01-10 17:44:04

 info   [2016-01-10 17:54:04.987]       thread-23       term-00, session end       = 2016-01-10 17:54:04

 info   [2016-01-10 17:54:04.987]       thread-23       term-00, transaction count = 1130640

<b>tpm : </b>

113487.61 + 113269.54 + 113247.19 + 113054.3 =  <b>453058.64</b>

第9分钟操作系统统计信息

top - 17:38:27 up 4 days,  8:32,  4 users,  load average: 78.54, 68.64, 37.22

tasks: 658 total,  34 running, 624 sleeping,   0 stopped,   0 zombie

cpu(s): 70.2%us, 15.7%sy,  0.0%ni,  5.5%id,  1.5%wa,  0.0%hi,  7.1%si,  0.0%st

mem:  264643396k total, 229866068k used, 34777328k free,    59652k buffers

swap: 18825200k total,        0k used, 18825200k free, 183529592k cached

          71.39    0.00   22.47    1.26    0.00    4.88

dfa               0.00     0.00 3659.33 7008.67 58538.67 112050.67    15.99     5.85    0.55   0.06  68.17

dfb               0.00     0.00 3714.67 6888.67 59418.67 110173.33    15.99     5.98    0.56   0.06  67.87

dfc               0.00     0.00 3709.00 6974.33 59328.00 111504.00    15.99     5.63    0.52   0.07  71.60

dm-0              0.00     0.00 11083.00 20870.33 177285.33 333706.67    15.99    17.60    0.55   0.03  92.10

测试过程oprofile报告

#/home/digoal/oprof/bin/opreport -l -f -w -x -t 0.5

using /soft/digoal/soft_bak/oprof_test/oprofile_data/samples/ for samples directory.

warning! some of the events were throttled. throttling occurs when

the initial sample rate is too high, causing an excessive number of

interrupts.  decrease the sampling frequency. check the directory

/soft/digoal/soft_bak/oprof_test/oprofile_data/samples/current/stats/throttled

for the throttled event names.

007a7780 2632700   5.2511  /soft/digoal/soft_bak/pgsql9.5/bin/postgres hash_search_with_hash_value

004a92f0 1895924   3.7816  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_compare

006969c0 1844371   3.6787  /soft/digoal/soft_bak/pgsql9.5/bin/postgres getsnapshotdata

0078a090 1775031   3.5404  /soft/digoal/soft_bak/pgsql9.5/bin/postgres searchcatcache

006a4bd0 1725350   3.4413  /soft/digoal/soft_bak/pgsql9.5/bin/postgres lwlockacquire

007bc3a0 1565190   3.1219  /soft/digoal/soft_bak/pgsql9.5/bin/postgres allocsetalloc

00498930 1406694   2.8058  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heap_hot_search_buffer

005b8f70 965646    1.9261  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execinitexpr

006895d0 767078    1.5300  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pinbuffer

004aaa80 617741    1.2321  /soft/digoal/soft_bak/pgsql9.5/bin/postgres _bt_checkkeys

007a2180 588043    1.1729  /soft/digoal/soft_bak/pgsql9.5/bin/postgres functioncall2coll

006a4220 575864    1.1486  /soft/digoal/soft_bak/pgsql9.5/bin/postgres lwlockrelease

007ac620 485162    0.9677  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pg_encoding_mbcliplen

007a3950 471102    0.9396  /soft/digoal/soft_bak/pgsql9.5/bin/postgres fmgr_info_cxt_security

0046c790 441548    0.8807  /soft/digoal/soft_bak/pgsql9.5/bin/postgres slot_deform_tuple

0048c8f0 425867    0.8494  /soft/digoal/soft_bak/pgsql9.5/bin/postgres hash_any

006b2e50 404548    0.8069  /soft/digoal/soft_bak/pgsql9.5/bin/postgres postgresmain

007bd0f0 396510    0.7909  /soft/digoal/soft_bak/pgsql9.5/bin/postgres palloc

0049bce0 394201    0.7863  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heap_page_prune_opt

007bce00 353243    0.7046  /soft/digoal/soft_bak/pgsql9.5/bin/postgres pfree

0049b300 335896    0.6700  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heap_page_prune

0046c580 313145    0.6246  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heap_getsysattr

006b14a0 311776    0.6219  /soft/digoal/soft_bak/pgsql9.5/bin/postgres exec_bind_message

007cb070 292106    0.5826  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heaptuplesatisfiesmvcc

007bd210 275282    0.5491  /soft/digoal/soft_bak/pgsql9.5/bin/postgres memorycontextalloczeroaligned

005b8530 273199    0.5449  /soft/digoal/soft_bak/pgsql9.5/bin/postgres execproject

00494ba0 266495    0.5315  /soft/digoal/soft_bak/pgsql9.5/bin/postgres heap_update

007bca10 265556    0.5297  /soft/digoal/soft_bak/pgsql9.5/bin/postgres allocsetfree

第二阶段oracle 12.1.0.2.0和postgresql 9.5.0 tpm 对比

PostgreSQL 9.5.0 PK Oracle 12.0.1.2.0 TPC-C性能极限

<b>阶段3,</b>

开启postgresql 预读, 大页支持, 分组提交:

listen_addresses = '0.0.0.0'         # what ip address(es) to listen on;

shared_buffers = 164gb                   # min 128kb

huge_pages = on                       # on, off, or try

bgwriter_lru_maxpages = 1000            # 0-1000 max buffers written/round

bgwriter_lru_multiplier = 10.0          # 0-10.0 multipler on buffers scanned/round

effective_io_concurrency = 2           # 1-1000; 0 disables prefetching

commit_delay = 10                       # range 0-100000, in microseconds

commit_siblings = 16                    # range 1-1000

checkpoint_timeout = 35min              # range 30s-1h

max_wal_size = 320gb

checkpoint_completion_target = 0.8     # checkpoint target duration, 0.0 - 1.0

$tail -n 5 benchmarksql-4.1.0_pg01/run/log/benchmarksql.log 

 info   [2016-01-11 13:33:55.917]       thread-14       term-00, measured tpmc (neworders) = 48151.07

 info   [2016-01-11 13:33:55.917]       thread-14       term-00, measured tpmtotal = 120215.48

 info   [2016-01-11 13:33:55.917]       thread-14       term-00, session start     = 2016-01-11 13:23:55

 info   [2016-01-11 13:33:55.917]       thread-14       term-00, session end       = 2016-01-11 13:33:55

 info   [2016-01-11 13:33:55.917]       thread-14       term-00, transaction count = 1202222

$tail -n 5 benchmarksql-4.1.0_pg02/run/log/benchmarksql.log 

 info   [2016-01-11 13:33:55.971]       thread-16       term-00, measured tpmc (neworders) = 48505.54

 info   [2016-01-11 13:33:55.971]       thread-16       term-00, measured tpmtotal = 121182.26

 info   [2016-01-11 13:33:55.971]       thread-16       term-00, session start     = 2016-01-11 13:23:55

 info   [2016-01-11 13:33:55.972]       thread-16       term-00, session end       = 2016-01-11 13:33:55

 info   [2016-01-11 13:33:55.972]       thread-16       term-00, transaction count = 1211858

$tail -n 5 benchmarksql-4.1.0_pg03/run/log/benchmarksql.log 

 info   [2016-01-11 13:33:55.985]       thread-4        term-00, measured tpmc (neworders) = 48119.61

 info   [2016-01-11 13:33:55.985]       thread-4        term-00, measured tpmtotal = 120523.98

 info   [2016-01-11 13:33:55.985]       thread-4        term-00, session start     = 2016-01-11 13:23:55

 info   [2016-01-11 13:33:55.985]       thread-4        term-00, session end       = 2016-01-11 13:33:55

 info   [2016-01-11 13:33:55.985]       thread-4        term-00, transaction count = 1205271

$tail -n 5 benchmarksql-4.1.0_pg04/run/log/benchmarksql.log 

 info   [2016-01-11 13:33:55.958]       thread-21       term-00, measured tpmc (neworders) = 48087.55

 info   [2016-01-11 13:33:55.958]       thread-21       term-00, measured tpmtotal = 120461.29

 info   [2016-01-11 13:33:55.958]       thread-21       term-00, session start     = 2016-01-11 13:23:55

 info   [2016-01-11 13:33:55.958]       thread-21       term-00, session end       = 2016-01-11 13:33:55

 info   [2016-01-11 13:33:55.958]       thread-21       term-00, transaction count = 1204638

<b>tpm:</b>

120215.48 + 121182.26 + 120523.98 + 120461.29 = <b>482383.01</b>

PostgreSQL 9.5.0 PK Oracle 12.0.1.2.0 TPC-C性能极限

<b>阶段4,</b>

优化分组提交的时延,最小结束点并发事务数量,work_mem等。

操作系统优化,

优化老化脏页刷新间隔

vm.dirty_writeback_centisecs=10

优化老化脏页阈值

vm.dirty_expire_centisecs=6000

优化用户进程刷脏页阈值

vm.dirty_ratio=80

优化内核进程刷脏页阈值

vm.dirty_background_bytes=102400000

优化终端数,每个benchmarksql 20个终端,一共80个终端。

listen_addresses = '0.0.0.0' # what ip address(es) to listen on;

port = 1921 # (change requires restart)

max_connections = 300 # (change requires restart)

unix_socket_directories = '.' # comma-separated list of directories

shared_buffers = 164gb # min 128kb

huge_pages = on # on, off, or try

work_mem = 256mb # min 64kb

maintenance_work_mem = 2gb # min 1mb

autovacuum_work_mem = 2gb # min 1mb, or -1 to use maintenance_work_mem

dynamic_shared_memory_type = mmap # the default is the first option

vacuum_cost_delay = 10 # 0-100 milliseconds

vacuum_cost_limit = 10000 # 1-10000 credits

bgwriter_delay = 10ms # 10-10000ms between rounds

bgwriter_lru_maxpages = 1000 # 0-1000 max buffers written/round

bgwriter_lru_multiplier = 10.0 # 0-10.0 multipler on buffers scanned/round

effective_io_concurrency = 2 # 1-1000; 0 disables prefetching

wal_level = minimal # minimal, archive, hot_standby, or logical

synchronous_commit = off # synchronization level;

full_page_writes = off # recover from partial page writes

wal_buffers = 128mb # min 32kb, -1 sets based on shared_buffers

wal_writer_delay = 10ms # 1-10000 milliseconds

commit_delay = 20 # range 0-100000, in microseconds

commit_siblings = 6 # range 1-1000

checkpoint_timeout = 55min # range 30s-1h

checkpoint_completion_target = 0.99 # checkpoint target duration, 0.0 - 1.0

random_page_cost = 1.0 # same scale as above

log_destination = 'csvlog' # valid values are combinations of

logging_collector = on # enable capturing of stderr and csvlog

log_truncate_on_rotation = on # if on, an existing log file with the

update_process_title = off

track_activities = off

autovacuum = on # enable autovacuum subprocess? 'on'

lc_messages = 'c' # locale for system error message

lc_monetary = 'c' # locale for monetary formatting

lc_numeric = 'c' # locale for number formatting

lc_time = 'c' # locale for time formatting

pg_ctl restart

dege.zzz@rds151163048-&gt; tail -n 5 benchmarksql-4.1.0_pg01/run/log/benchmarksql.log

info [2016-01-12 11:55:09.461] thread-12 term-00, measured tpmc (neworders) = 57995.55

info [2016-01-12 11:55:09.461] thread-12 term-00, measured tpmtotal = 144975.59

info [2016-01-12 11:55:09.461] thread-12 term-00, session start = 2016-01-12 11:45:09

info [2016-01-12 11:55:09.461] thread-12 term-00, session end = 2016-01-12 11:55:09

info [2016-01-12 11:55:09.462] thread-12 term-00, transaction count = 1449796

dege.zzz@rds151163048-&gt; tail -n 5 benchmarksql-4.1.0_pg02/run/log/benchmarksql.log

info [2016-01-12 11:55:09.499] thread-0 term-00, measured tpmc (neworders) = 58013.75

info [2016-01-12 11:55:09.499] thread-0 term-00, measured tpmtotal = 145006.74

info [2016-01-12 11:55:09.499] thread-0 term-00, session start = 2016-01-12 11:45:09

info [2016-01-12 11:55:09.500] thread-0 term-00, session end = 2016-01-12 11:55:09

info [2016-01-12 11:55:09.500] thread-0 term-00, transaction count = 1450110

dege.zzz@rds151163048-&gt; tail -n 5 benchmarksql-4.1.0_pg03/run/log/benchmarksql.log

info [2016-01-12 11:55:09.541] thread-14 term-00, measured tpmc (neworders) = 57322.05

info [2016-01-12 11:55:09.541] thread-14 term-00, measured tpmtotal = 143227.03

info [2016-01-12 11:55:09.542] thread-14 term-00, session start = 2016-01-12 11:45:09

info [2016-01-12 11:55:09.542] thread-14 term-00, session end = 2016-01-12 11:55:09

info [2016-01-12 11:55:09.542] thread-14 term-00, transaction count = 1432298

dege.zzz@rds151163048-&gt; tail -n 5 benchmarksql-4.1.0_pg04/run/log/benchmarksql.log

info [2016-01-12 11:55:09.574] thread-7 term-00, measured tpmc (neworders) = 57863.92

info [2016-01-12 11:55:09.574] thread-7 term-00, measured tpmtotal = 144596.45

info [2016-01-12 11:55:09.575] thread-7 term-00, session start = 2016-01-12 11:45:09

info [2016-01-12 11:55:09.575] thread-7 term-00, session end = 2016-01-12 11:55:09

info [2016-01-12 11:55:09.575] thread-7 term-00, transaction count = 1445978

<b>tpm:</b>

144975.59 + 145006.74 + 143227.03 + 144596.45 = <b>577805.81</b>

阶段5,

intel编译器

clang编译器

$ export ld_library_path=/u02/digoal/gcc4.9.3/lib:/u02/digoal/cloog/lib:/u02/digoal/gmp/lib:/u02/digoal/isl/lib:/u02/digoal/mpc/lib:/u02/digoal/mpfr/lib:$ld_library_path

$ export path=/u02/digoal/gcc4.9.3/bin:$path

$ cflags="-o3 -march=native -flto" cc=/u02/digoal/gcc4.9.3/bin/gcc ./configure --prefix=/u02/digoal/soft_bak/pgsql9.5 --with-blocksize=32 --with-pgport=1921 --with-perl --with-python --with-tcl --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt --enable-thread-safety --with-wal-segsize=64

$ make world -j 32

$ make install-world -j 32

$ pg_config 

digoal tail -n 5 benchmarksql-4.1.0_pg01/run/log/benchmarksql.log 

 info   [2016-01-13 02:00:49.699]       thread-15       term-00, measured tpmc (neworders) = 59092.33

 info   [2016-01-13 02:00:49.699]       thread-15       term-00, measured tpmtotal = 147832.44

 info   [2016-01-13 02:00:49.699]       thread-15       term-00, session start     = 2016-01-13 01:50:49

 info   [2016-01-13 02:00:49.699]       thread-15       term-00, session end       = 2016-01-13 02:00:49

 info   [2016-01-13 02:00:49.699]       thread-15       term-00, transaction count = 1478385

digoal tail -n 5 benchmarksql-4.1.0_pg02/run/log/benchmarksql.log 

 info   [2016-01-13 02:00:49.704]       thread-0        term-00, measured tpmc (neworders) = 60051.49

 info   [2016-01-13 02:00:49.704]       thread-0        term-00, measured tpmtotal = 150231.54

 info   [2016-01-13 02:00:49.704]       thread-0        term-00, session start     = 2016-01-13 01:50:49

 info   [2016-01-13 02:00:49.704]       thread-0        term-00, session end       = 2016-01-13 02:00:49

 info   [2016-01-13 02:00:49.704]       thread-0        term-00, transaction count = 1502367

digoal tail -n 5 benchmarksql-4.1.0_pg03/run/log/benchmarksql.log 

 info   [2016-01-13 02:00:49.693]       thread-16       term-00, measured tpmc (neworders) = 60273.99

 info   [2016-01-13 02:00:49.694]       thread-16       term-00, measured tpmtotal = 150601.93

 info   [2016-01-13 02:00:49.694]       thread-16       term-00, session start     = 2016-01-13 01:50:49

 info   [2016-01-13 02:00:49.694]       thread-16       term-00, session end       = 2016-01-13 02:00:49

 info   [2016-01-13 02:00:49.694]       thread-16       term-00, transaction count = 1506066

digoal tail -n 5 benchmarksql-4.1.0_pg04/run/log/benchmarksql.log 

 info   [2016-01-13 02:00:49.715]       thread-18       term-00, measured tpmc (neworders) = 60180.69

 info   [2016-01-13 02:00:49.715]       thread-18       term-00, measured tpmtotal = 150591.78

 info   [2016-01-13 02:00:49.716]       thread-18       term-00, session start     = 2016-01-13 01:50:49

 info   [2016-01-13 02:00:49.716]       thread-18       term-00, session end       = 2016-01-13 02:00:49

 info   [2016-01-13 02:00:49.716]       thread-18       term-00, transaction count = 1505962

<b>tpm</b>

<b>599257.69</b>

[其他优化手段]

1. postgresql jdbc有一些参数可以优化,本文还未处理。例如防止类型转换,query plan cache size。

http://www.postgresql.org/docs/9.2/interactive/libpq-connect.html

2. postgresql 代码层也有优化的空间,例如分区表的代码,快照的优化。

[特别声明]

1. 本文纯属技术交流,测试数据不具备任何指导意义。

[参考]

1. http://commons.apache.org/proper/commons-logging/apidocs/org/apache/commons/logging/impl/log4jlogger.html