test luadbi's postgresql driver performance (vs pgbench)

测试机环境 : 

Lua 5.1.5
CentOS 5.7 x64
PostgreSQL 9.3.2
CPU
model name      : Intel(R) Xeon(R) CPU           E5440  @ 2.83GHz
stepping        : 6
cpu MHz         : 2833.435

Luadbi测试结果 : 

[root@db-172-16-3-33 luadbi]# taskset -c 2 /opt/lua5.1/bin/lua
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> require "DBI"
> dbh = assert(DBI.Connect('PostgreSQL', 'digoal', 'digoal', 'digoal', '/home/postgres/pg_root_5432', '5432'))
> dbh:autocommit(true)
> insert = assert(dbh:prepare("select ?::int"))
> function foo(cnt)
>>   local var1 = os.time()
>>   for i = 1,cnt do
>>     insert:execute(1)
>>   end
>>   return (os.time()-var1)
>> end
> print(foo(100000))
6
> print(foo(1000000))
61
> = 1000000/61.0;
16393.442622951

pgbench测试结果 : 

postgres@db-172-16-3-33-> vi test.sql
\set v 10
select :v::int;

postgres@db-172-16-3-33-> taskset -c 2 pgbench -M prepared -n -r -f ./test.sql -c 1 -j 1 -T 30 -U digoal digoal
transaction type: Custom query
scaling factor: 1
query mode: prepared
number of clients: 1
number of threads: 1
duration: 30 s
number of transactions actually processed: 561432
tps = 18713.732544 (including connections establishing)
tps = 18715.020715 (excluding connections establishing)
statement latencies in milliseconds:
        0.001098        \set v 10
        0.050809        select :v::int;

同一机器下面lua5.1+luapgsql的测试结果

root@db-172-16-3-33-> taskset -c 2 /opt/lua5.1/bin/lua
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> require "pgsql"
> conn = pgsql.connectdb('host=/home/postgres/pg_root_5432 port=5432 dbname=digoal user=digoal password=digoal')
> print(conn:errorMessage())

> conn:prepare('pre5','select $1',23)
> conn:execPrepared('pre5','10')
> function foo(cnt)
>>   local var1 = os.time()
>>   for i = 1,cnt do
>>     conn:execPrepared('pre5','10')
>>   end
>>   return (os.time()-var1)
>> end
> print(foo(100000))
6
> print(foo(1000000))
55
> = 1000000/55.0
18181.818181818

使用Lua 5.1和luadbi连接postgresql进行测试, 相比pgbench损失性能12.4%.

从性能角度来讲, 建议使用luapgsql连接PostgreSQL.

[参考]
1. http://blog.163.com/digoal@126/blog/static/163877040201412205316943/

2. http://blog.163.com/digoal@126/blog/static/163877040201412143349217/

3. http://blog.163.com/digoal@126/blog/static/163877040201412125644452/

时间: 2024-08-01 17:56:02

test luadbi's postgresql driver performance (vs pgbench)的相关文章

test luasql's postgresql driver performance (not better than pgbench)

测试数据库性能的方法很多, 例如使用pgbench, sysbench. 对PostgreSQL而言, pgbench是性能损失最小的一种测试工具, 本文将使用lua以及luasql驱动测试一下, 我们对比一下使用lua和pgbench测试的结果, 看看lua会带来多少性能损失. 本文测试环境 :  Lua 5.2.3 CentOS 6.4 x64 PostgreSQL 9.3.1 CPU model name : Intel(R) Xeon(R) CPU E5504 @ 2.00GHz ste

test luapgsql driver performance (vs pgbench)

前面我们测试了luasql这个驱动的性能, 无法达到pgbench的性能. 损失17%左右, 原因是luasql不支持prepared sql. 这篇将介绍一下luapgsql这个驱动的性能. 首先要在环境中安装, 前面的安装是在CentOS 5.x中安装的, 需要依赖libbsd-devel包(bsd/bsd.h头文件) 环境 Lua 5.2.3 CentOS 6.4 x64 PostgreSQL 9.3.1 CPU model name : Intel(R) Xeon(R) CPU E550

mongoDB VS PostgreSQL dml performance use python (pymongo & py-postgresql)

前面测试了mongodb和postgresql的插入性能对比, 参考如下 :  1. http://blog.163.com/digoal@126/blog/static/16387704020151435825593/ 2. http://blog.163.com/digoal@126/blog/static/1638770402015142858224/ 3. http://blog.163.com/digoal@126/blog/static/16387704020151210840303

psycopg2 postgresql driver for python don't support prepared statement Direct

前面使用py-postgresql测试过PostgreSQL性能, 可能是这个驱动效率较低, 我们接下来使用psycopg2测试一下. psycopg2使用libpq接口, 支持2PC, 支持异步提交等, 但是不支持绑定变量. 安装 [root@localhost ~]# . /home/postgres/.bash_profile root@localhost-> which pg_config /opt/pgsql9.3.5/bin/pg_config [root@localhost ~]#

PgSQL · 性能优化 · PostgreSQL TPC-C极限优化玩法

简介 本文以工业界测试模型TPC-C为测试模型,介绍PostgreSQL数据库从系统层面的优化到数据库层面的优化方法. TPmC从 256195.32 提升到 606466.31 是如何做到的. 测试环境介绍 16核开HT共32线程 256G 1600MHz 内存 万兆网卡 3 块 6.4TB AliFlash PCI-E SSD 逻辑卷条带 XFS 数据块对齐 XFS文件系统优化 主要分3块: 逻辑卷优化部分 XFS mkfs 优化部分 XFS mount 优化部分 以上几个部分都可以通过ma

PostgreSQL 9.5 新特性 高斯(正态)分布和指数分布 数据生成器

PostgreSQL 9.5 对pgbench的功能增强. Allow counting of pgbench transactions that take over a specified amount of time (Fabien Coelho) This is controlled by new --latency-limit option. Allow pgbench to generate Gaussian/exponential distributions using \setra

Install SysBench support MySQL and PostgreSQL

[测试环境] CentOS 5.7 x64 [安装MySQL] 1. 下载Mysql Red Hat & Oracle Linux 5 (x86, 64-bit), RPM Package MySQL Server 5.6.11 84.2M Download (MySQL-server-5.6.11-2.rhel5.x86_64.rpm) MD5: 944e3e425becf3ef7ad5f191e0e1f04f 2. 安装Mysql rpm -ivh MySQL-server-5.6.11-2

实战 Eclipse ,Jigloo, PostgreSQL,JDBC 开发数据库查询应用系统起步

数据|数据库 实战 Eclipse ,Jigloo, PostgreSQL,JDBC 开发数据库查询应用系统起步 1 安装 Eclipse笔者用的GNU/Linux先从 下载了些GTK+相关的包编译安装之后,到Eclipse主页上 找到了Linux下GTK的 Eclipse安装文件 2 .插件笔者安装了两个插件一个是GUI设计工具 jigloo,主页:http://cloudgarden.com/jigloo/ 一个是打包工具 fat jar exporterhttp://fjep.source

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 新版本性能咋样? benchma