Skip to content

Commit 4f77606

Browse files
author
Nicola Strappazzon C
committed
add more benchmarks, varchar case
1 parent df74678 commit 4f77606

24 files changed

+1941
-1127
lines changed

README.md

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,98 @@ Each direcyory have a specific test case.
1818
-
1919
-
2020

21+
## Hardware
22+
23+
- db.m5.xlarge (4vCPU, 16GiB RAM, 1000 IOPS (io1), ) zone a.
24+
- db.m6g.xlarge (4vCPU, 8GiB RAM, 1000 IOPS (io1), )
25+
26+
- bastion, zone a.
27+
2128
## Requirement
2229

23-
Create a MySQL database and user for sysbench:
30+
Create a RDS:
31+
32+
```
33+
aws rds create-db-instance \
34+
--db-instance-identifier benchmark \
35+
--db-instance-class db.t3.micro \
36+
--engine mysql \
37+
--engine-version 8.0.28 \
38+
--master-username admin \
39+
--master-user-password admin123 \
40+
--allocated-storage 100 \
41+
--vpc-security-group-ids sg-088a458cf7e281afe \
42+
--availability-zone eu-west-1a \
43+
--db-subnet-group-name thn-stg-generic-db \
44+
--backup-retention-period 0 \
45+
--no-enable-performance-insights \
46+
--no-multi-az
47+
```
48+
49+
Bastion
50+
51+
Install sysbench on your Amazon Linux:
2452

2553
```bash
26-
mysql> CREATE SCHEMA sbtest;
27-
mysql> GRANT ALL PRIVILEGES ON sbtest.* TO sbtest@'localhost' IDENTIFIED BY 'sbtest';
28-
mysql> FLUSH PRIVILEGES;
54+
sudo yum install gnuplot
55+
```
2956

57+
```bash
58+
sudo yum -y install git gcc make automake libtool openssl-devel ncurses-compat-libs
3059
```
60+
61+
```bash
62+
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
63+
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
64+
sudo yum -y update
65+
```
66+
67+
```bash
68+
sudo yum -y install mysql-community-devel mysql-community-client mysql-community-common
69+
```
70+
71+
72+
```bash
73+
git clone https://github.com/akopytov/sysbench
74+
```
75+
76+
5. Build the binary
77+
78+
```bash
79+
cd sysbench
80+
git checkout tags/1.0.20
81+
./autogen.sh
82+
./configure
83+
make
84+
sudo make install
85+
```
86+
87+
6. You can verify the installation by:
88+
89+
```bash
90+
sysbench --version
91+
```
92+
93+
7. Create a MySQL database and user for sysbench:
94+
95+
MySQL 5.x
96+
97+
```sql
98+
CREATE SCHEMA sbtest;
99+
GRANT ALL PRIVILEGES ON sbtest.* TO sbtest@'%' IDENTIFIED BY 'sbtest';
100+
FLUSH PRIVILEGES;
101+
```
102+
103+
MySQL 8.0
104+
105+
```sql
106+
CREATE SCHEMA sbtest;
107+
CREATE USER 'sbtest'@'%' IDENTIFIED WITH mysql_native_password BY 'sbtest';
108+
GRANT ALL PRIVILEGES ON sbtest.* TO 'sbtest'@'%';
109+
FLUSH PRIVILEGES;
110+
```
111+
112+
export MYSQL_HOST="benchmark.cse2qkeganda.eu-west-1.rds.amazonaws.com"
113+
mysql -h $MYSQL_HOST -u sbtest -psbtest -e "show databases"
114+
115+
join

doc/queries.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Queries
2+
3+
Used queries to get more details for each case.
4+
5+
Index size:
6+
7+
```sql
8+
SELECT ROUND(stat_value * @@innodb_page_size / 1024 / 1024, 2) AS size_in_mb
9+
FROM mysql.innodb_index_stats
10+
WHERE stat_name = 'size' AND table_name = 'uuid_varchar';
11+
```
12+
13+
Table size:
14+
15+
```sql
16+
SELECT ROUND((data_length + index_length) / 1024 / 1024) AS size_in_mb, table_rows AS 'rows'
17+
FROM information_schema.tables
18+
WHERE table_name = 'uuid_varchar';
19+
```

doc/tips.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Tips
2+
3+
## CHAR vs VARCHAR
4+
5+
There is insignificant difference especially considering CHAR has a maximum length of 255 (VARCHAR is 64K). With the effective equivalent limited to 255 that is a very quick comparison in the case of this field being used as join criteria.
6+
7+
The fragmentation is no longer an consideration as <768 bytes is stored inline. This is still strictly possible in utf8mb4, "InnoDB encodes fixed-length fields greater than or equal to 768 bytes in length as variable-length fields"1 so no difference between CHAR and VARCHAR.
8+
9+
https://dev.mysql.com/doc/refman/8.0/en/char.html

primary_key/README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Primary Keys
22

3-
![Bigint](https://raw.githubusercontent.com/swapbyt3s/MySQLBenchmarks/master/primary_key/bigint/bigint.svg?sanitize=true)
4-
![Binary](https://raw.githubusercontent.com/swapbyt3s/MySQLBenchmarks/master/primary_key/binary/binary.svg?sanitize=true)
5-
![Char](https://raw.githubusercontent.com/swapbyt3s/MySQLBenchmarks/master/primary_key/char/char.svg?sanitize=true)
3+
Comparing common data type performance, each test is running up 30 minutes, and work 1000000 rows approximate.
4+
5+
![BIGINT](https://raw.githubusercontent.com/swapbyt3s/MySQLBenchmarks/master/primary_key/bigint/bigint.svg?sanitize=true)
6+
![BINARY](https://raw.githubusercontent.com/swapbyt3s/MySQLBenchmarks/master/primary_key/binary/binary.svg?sanitize=true)
7+
![CHAR](https://raw.githubusercontent.com/swapbyt3s/MySQLBenchmarks/master/primary_key/char/char.svg?sanitize=true)
8+
![VARCHAR](https://raw.githubusercontent.com/swapbyt3s/MySQLBenchmarks/master/primary_key/varchar/varchar.svg?sanitize=true)

primary_key/bigint/bigint.pg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/local/bin/gnuplot
1+
#!/usr/bin/gnuplot
22
reset
33

44
# Titles & Axis Labels

primary_key/bigint/bigint.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,38 @@
11
#!/bin/bash
22
# encoding: UTF-8
33

4+
set -e
5+
46
./insert.lua \
7+
--mysql-host=$MYSQL_HOST \
58
--mysql-password=sbtest \
6-
prepare
9+
prepare > /dev/null
710

811
./insert.lua \
12+
--mysql-host=$MYSQL_HOST \
913
--mysql-password=sbtest \
1014
--threads=1 \
1115
--report-interval=1 \
12-
--max-time=300 \
16+
--max-time=1800 \
1317
run > insert.log
1418

1519
./select.lua \
20+
--mysql-host=$MYSQL_HOST \
1621
--mysql-password=sbtest \
1722
--threads=1 \
1823
--report-interval=1 \
19-
--max-time=300 \
20-
--thread-init-timeout=120 \
24+
--max-time=1800 \
2125
run > select.log
2226

2327
./insert.lua \
28+
--mysql-host=$MYSQL_HOST \
2429
--mysql-password=sbtest \
25-
cleanup
30+
cleanup > /dev/null
2631

27-
cat insert.log | egrep '\d+\;\d+\.\d+\;\d+\;\d+\.\d+' > insert.csv
28-
cat select.log | egrep '\d+\;\d+\.\d+\;\d+\.\d+' > select.csv
32+
cat insert.log | grep -Eo '[0-9]*;[0-9]*.[0-9]*' > insert.csv
33+
cat select.log | grep -Eo '[0-9]*;[0-9]*.[0-9]*' > select.csv
2934

3035
./bigint.pg
3136

32-
open -a "Gapplin" bigint.svg
33-
3437
rm insert{.log,.csv}
3538
rm select{.log,.csv}

0 commit comments

Comments
 (0)