测试数据库schema:
drop table if exists t1;
drop table if exists t2;
drop table if exists t3;
create table t1(id int primary key, value1 int, value2 varchar(200));
create index s1 on t1(value1);
create table t2(id int primary key, value1 int, value2 varchar(200));
create index s2 on t2(value1);
create table t3(id int primary key, value1 int, value2 varchar(200));
create index s3 on t3(value1);
t1:1000万行;t2:1亿行;t3:3亿行。
id是连续的;value1为0 - 1000000000之间的随机值;value2为平均长度为100,最大长度为200的字符串。
PG和MySQL的配置请看:
http://blog.csdn.net/liyuming0000/article/details/51023511
http://blog.csdn.net/liyuming0000/article/details/51014191
测试负载:
1. 单表上的不同类型读负载
单点(主键)随机读负载
主键范围读负载
非主键的读(二级索引读)负载
2. 短事务
单行更新操作(insert、delete、replace、update)
QPS:每秒查询数
QRS:查询响应时间(单位为ms)
TPS:每秒事务数
TRS:事务响应时间(单位为ms)
统计表中第二栏的响应时间与第一栏的每秒操作数按顺序一一对应
实验一
实验目的:测试MySQL和PG针对主键随机读负载的最优吞吐量。
测试负载:select value1 from table where id = ?,以预编译的形式执行,id是在主键范围上均匀分布。
MySQL:
数据表t1:
线程数 |
QPS |
QRS |
10 |
35522, 36419 |
0.285, 0.279 |
20 |
64540, 64716 |
0.314, 0.313 |
50 |
107399, 105946 |
0.473, 0.480 |
100 |
109425, 110050 |
0.922, 0.917 |
150 |
109569, 111209 |
1.381, 1.361 |
200 |
115449, 115601 |
1.747, 1.744 |
250 |
116336, 116004 |
2.167, 2.173 |
300 |
115520, 115265 |
2.626, 2.629 |
数据表t2:
线程数 |
QPS |
QRS |
10 |
2679, 35821 |
3.735, 0.282 |
20 |
22583, 63940 |
0.889, 0.316 |
50 |
81851, 107456 |
0.619, 0.474 |
100 |
94480, 109425 |
1.068, 0.921 |
150 |
108686, 109180 |
1.390, 1.387 |
200 |
116322, 115101 |
1.733, 1.751 |
250 |
116211, 114987 |
2.168, 2.190 |
300 |
115134, 114702 |
2.630, 2.643 |
数据表t3:
线程数 |
QPS |
QRS |
10 |
1110, 30518 |
8.989, 0.331 |
20 |
3717, 52904 |
5.369, 0.384 |
50 |
18882, 75080 |
2.655, 0.675 |
100 |
42844, 87145 |
2.342, 1.156 |
150 |
98669, 91366 |
1.530, 1.654 |
200 |
61733, 88915 |
3.247, 2.259 |
250 |
67503, 85314 |
3.712, 2.942 |
300 |
88601, 84400 |
3.407, 3.570 |
PG:
数据表t1:
线程数 |
QPS |
QRS |
10 |
37879, 38148, 12728, 38237 |
0.275, 0.266, 0.790, 0.265 |
20 |
75037, 68906, 78759, 77142 |
0.273, 0.294, 0.261, 0.265 |
50 |
139676, 135779, 137780, 135497 |
0.366, 0.375, 0.371, 0.377 |
100 |
181549, 185476, 175890, 173170 |
0.560, 0.548, 0.580, 0.588 |
150 |
222857, 219711, 230571, 204284 |
0.695, 0.698, 0.670, 0.751 |
200 |
245709, 231214, 245812, 240065 |
0.834, 0.878, 0.836, 0.851 |
250 |
246533, 228139, 248405, 238104 |
1.044, 1.115, 1.041, 1.075 |
300 |
246229, 237196, 239975, 226885 |
1.259, 1.302, 1.294, 1.357 |
数据表t2:
线程数 |
QPS |
QRS |
10 |
30784, 37991, 917, 35821 |
0.329, 0.274, 10.867, 0.282 |
20 |
54830, 70700, 7591, 72989 |
0.370, 0.287, 2.636, 0.280 |
50 |
122400, 136795, 91058, 137434 |
0.417, 0.374, 0.558, 0.372 |
100 |
131690, 180934, 132992, 179460 |
0.768, 0.563, 0.780, 0.567 |
150 |
152968, 206199, 196900, 217128 |
0.993, 0.743, 0.776, 0.706 |
200 |
182414, 221721, 221870, 221576 |
1.112, 0.924, 0.921, 0.921 |
250 |
212466, 225449, 221794, 215628 |
1.210, 1.142, 1.154, 1.184 |
300 |
168306, 212136, 211857, 206145 |
1.813, 1.455, 1.456, 1.491 |
数据表t3:
线程数 |
QPS |
QRS |
10 |
330, 1958, 961, 5021 |
29.612, 5.097, 10.348, 1.993 |
20 |
1728, 4049, 4533, 31004 |
11.522, 4.935, 4.406, 0.649 |
50 |
3158, 6568, 7593, 83657 |
15.717, 7.596, 6.574, 0.606 |
100 |
3520, 25436, 9688, 108118 |
27.875, 3.933, 10.279, 0.934 |
150 |
3600, 23254, 10862, 121425 |
40.687, 6.445, 13.718, 1.247 |
200 |
3497, 70062, 14395, 124518 |
55.519, 2.862, 13.801, 1.618 |
250 |
3500, 121358, 10639, 27538 |
69.554, 2.096, 23.299, 9.050 |
300 |
3321, 19276, 6610, 99964 |
84.137, 15.477, 44.068, 3.024 |
实验二
实验目的:测试MySQL和PG针对主键范围读负载的最优吞吐量。
测试负载:select value1 from table where id between ? and ?,以预编译的形式执行,第一个id在主键范围上均匀分布,range大小为0- 100的一个随机值。
MySQL:
数据表t1:
线程数 |
QPS |
QRS |
10 |
22452, 25006 |
0.449, 0.403 |
20 |
43140, 43006 |
0.468, 0.472 |
50 |
70608, 70080 |