diff --git a/README.md b/README.md index 2a24702..22b22e0 100644 --- a/README.md +++ b/README.md @@ -9,14 +9,20 @@ And with gnuplot we generate graphs in `.SVG` files and you can see with Each direcyory have a specific test case. - Primary Key: Test the best data type for this purpose. -- Random: +- Random: Generate only random data. +- Row Format: Compressed VS Dynamic ## Consideration -- -- -- -- +- El número de TPS or QPS será proporcional al rendimiento ofrecido por la CPU y los IOPS entre otros. + +## Install + +```bash +brew install mysql@5.7 +brew install sysbench +brew install gnuplot +``` ## Requirement diff --git a/row_format/README.md b/row_format/README.md new file mode 100644 index 0000000..bb58991 --- /dev/null +++ b/row_format/README.md @@ -0,0 +1,4 @@ +# Row Format + +![Compressed](https://raw.githubusercontent.com/swapbyt3s/MySQLBenchmarks/master/row_format/compressed/compressed.svg?sanitize=true) +![Dynamic](https://raw.githubusercontent.com/swapbyt3s/MySQLBenchmarks/master/row_format/dynamic/dynamic.svg?sanitize=true) diff --git a/row_format/compressed/compressed.pg b/row_format/compressed/compressed.pg new file mode 100755 index 0000000..95e87f6 --- /dev/null +++ b/row_format/compressed/compressed.pg @@ -0,0 +1,28 @@ +#!/usr/local/bin/gnuplot +reset + +# Titles & Axis Labels +set title 'Benchmark ROW_FORMAT with COMPRESSED type by tps/qps' +set xlabel 'Duration (s)' +set ylabel 'Transactions and Queries (tps/qps)' + +# Output +set terminal svg size 800,380 font 'Verdana,10' +set output 'compressed.svg' + +# Grid +set grid +set key outside top right vertical +set tics out nomirror + +# Lines +set style data line +set style line 1 linecolor rgb '#0060ad' +set style line 2 linecolor rgb '#3ADF00' + +# Input data +set datafile separator ";" + +# TPS +plot 'insert.csv' using 0:2 linestyle 1 title 'Inserts', \ + 'select.csv' using 0:2 linestyle 2 title 'Select' diff --git a/row_format/compressed/compressed.sh b/row_format/compressed/compressed.sh new file mode 100755 index 0000000..961b57f --- /dev/null +++ b/row_format/compressed/compressed.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# encoding: UTF-8 + +./insert.lua \ + --mysql-password=sbtest \ + prepare + +./insert.lua \ + --mysql-password=sbtest \ + --threads=1 \ + --report-interval=1 \ + --max-time=300 \ + run > insert.log + +./select.lua \ + --mysql-password=sbtest \ + --threads=1 \ + --report-interval=1 \ + --max-time=300 \ + --thread-init-timeout=120 \ + run > select.log + +./insert.lua \ + --mysql-password=sbtest \ + cleanup + +cat insert.log | egrep '\d+\;\d+' > insert.csv +cat select.log | egrep '\d+\;\d+' > select.csv + +./compressed.pg + +open -a "Gapplin" compressed.svg + +rm insert{.log,.csv} +rm select{.log,.csv} diff --git a/row_format/compressed/compressed.svg b/row_format/compressed/compressed.svg new file mode 100644 index 0000000..9812e68 --- /dev/null +++ b/row_format/compressed/compressed.svg @@ -0,0 +1,346 @@ + + + +Gnuplot +Produced by GNUPLOT 5.2 patchlevel 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2000 + + + + + + + + + + + + + 4000 + + + + + + + + + + + + + 6000 + + + + + + + + + + + + + 8000 + + + + + + + + + + + + + 10000 + + + + + + + + + + + + + 12000 + + + + + + + + + + + + + 14000 + + + + + + + + + + + + + 16000 + + + + + + + + + + + + + 18000 + + + + + + + + + + + + + 20000 + + + + + + + + + + + + + 0 + + + + + + + + + + + + + 20 + + + + + + + + + + + + + 40 + + + + + + + + + + + + + 60 + + + + + + + + + + + + + 80 + + + + + + + + + + + + + 100 + + + + + + + + + + + + + 120 + + + + + + + + + Transactions and Queries (tps/qps) + + + + + Duration (s) + + + + + Benchmark ROWFORMAT with COMPRESSED type by tps/qps + + + + + Inserts + + + Inserts + + + + + + Select + + + Select + + + + + + + + + + + + + + + + + + diff --git a/row_format/compressed/insert.lua b/row_format/compressed/insert.lua new file mode 100755 index 0000000..7170bfb --- /dev/null +++ b/row_format/compressed/insert.lua @@ -0,0 +1,56 @@ +#!/usr/bin/env sysbench + +local c_value_template = "###########-###########-###########-" .. + "###########-###########-###########-" .. + "###########-###########-###########-" .. + "###########" + +function prepare() + local drv = sysbench.sql.driver() + local con = drv:connect() + + con:query(string.format([[ + CREATE TABLE IF NOT EXISTS sbtest ( + id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + c VARCHAR(120) DEFAULT '' NOT NULL, + PRIMARY KEY (id) + ) ENGINE=InnoDB ROW_FORMAT=COMPRESSED + ]])) +end + +function cleanup() + local drv = sysbench.sql.driver() + local con = drv:connect() + + con:query("DROP TABLE IF EXISTS sbtest") +end + +function thread_init() + drv = sysbench.sql.driver() + con = drv:connect() +end + +function get_c_value() + return sysbench.rand.string(c_value_template) +end + +function event () + query = string.format("INSERT INTO sbtest (c) VALUES ('%s')", get_c_value()) + + con:query(query) +end + +function thread_done() + con:disconnect() +end + +function sysbench.hooks.report_intermediate(stat) + drv = sysbench.sql.driver() + con = drv:connect() + + print(string.format("%.0f;%d", + stat.time_total, + stat.events + )) +end + diff --git a/row_format/compressed/select.lua b/row_format/compressed/select.lua new file mode 100755 index 0000000..dc7a88b --- /dev/null +++ b/row_format/compressed/select.lua @@ -0,0 +1,33 @@ +#!/usr/bin/env sysbench + +function thread_init() + drv = sysbench.sql.driver() + con = drv:connect() +end + +function event () + -- Maybe to optimize the second arg on math.random(1, 460000) + -- is good to take first select max(id) from sbtest; and round. + -- + local rnd = math.random(1, 460000) + local sql = [[ + SELECT SQL_NO_CACHE * + FROM sbtest + WHERE id = %d + ]] + + con:query(string.format(sql, rnd)) +end + +function thread_done() + con:disconnect() +end + +function sysbench.hooks.report_intermediate(stat) + local seconds = stat.time_interval + + print(string.format("%.0f;%d", + stat.time_total, + stat.events + )) +end diff --git a/row_format/dynamic/dynamic.pg b/row_format/dynamic/dynamic.pg new file mode 100755 index 0000000..1e6786e --- /dev/null +++ b/row_format/dynamic/dynamic.pg @@ -0,0 +1,28 @@ +#!/usr/local/bin/gnuplot +reset + +# Titles & Axis Labels +set title 'Benchmark ROW_FORMAT with DYNAMIC type by tps/qps' +set xlabel 'Duration (s)' +set ylabel 'Transactions and Queries (tps/qps)' + +# Output +set terminal svg size 800,380 font 'Verdana,10' +set output 'dynamic.svg' + +# Grid +set grid +set key outside top right vertical +set tics out nomirror + +# Lines +set style data line +set style line 1 linecolor rgb '#0060ad' +set style line 2 linecolor rgb '#3ADF00' + +# Input data +set datafile separator ";" + +# TPS +plot 'insert.csv' using 0:2 linestyle 1 title 'Inserts', \ + 'select.csv' using 0:2 linestyle 2 title 'Select' diff --git a/row_format/dynamic/dynamic.sh b/row_format/dynamic/dynamic.sh new file mode 100755 index 0000000..2068ca1 --- /dev/null +++ b/row_format/dynamic/dynamic.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# encoding: UTF-8 + +./insert.lua \ + --mysql-password=sbtest \ + prepare + +./insert.lua \ + --mysql-password=sbtest \ + --threads=1 \ + --report-interval=1 \ + --max-time=300 \ + run > insert.log + +./select.lua \ + --mysql-password=sbtest \ + --threads=1 \ + --report-interval=1 \ + --max-time=300 \ + --thread-init-timeout=120 \ + run > select.log + +./insert.lua \ + --mysql-password=sbtest \ + cleanup + +cat insert.log | egrep '\d+\;\d+' > insert.csv +cat select.log | egrep '\d+\;\d+' > select.csv + +./dynamic.pg + +open -a "Gapplin" dynamic.svg + +rm insert{.log,.csv} +rm select{.log,.csv} diff --git a/row_format/dynamic/dynamic.svg b/row_format/dynamic/dynamic.svg new file mode 100644 index 0000000..74020e5 --- /dev/null +++ b/row_format/dynamic/dynamic.svg @@ -0,0 +1,346 @@ + + + +Gnuplot +Produced by GNUPLOT 5.2 patchlevel 8 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2000 + + + + + + + + + + + + + 4000 + + + + + + + + + + + + + 6000 + + + + + + + + + + + + + 8000 + + + + + + + + + + + + + 10000 + + + + + + + + + + + + + 12000 + + + + + + + + + + + + + 14000 + + + + + + + + + + + + + 16000 + + + + + + + + + + + + + 18000 + + + + + + + + + + + + + 20000 + + + + + + + + + + + + + 0 + + + + + + + + + + + + + 20 + + + + + + + + + + + + + 40 + + + + + + + + + + + + + 60 + + + + + + + + + + + + + 80 + + + + + + + + + + + + + 100 + + + + + + + + + + + + + 120 + + + + + + + + + Transactions and Queries (tps/qps) + + + + + Duration (s) + + + + + Benchmark ROWFORMAT with DYNAMIC type by tps/qps + + + + + Inserts + + + Inserts + + + + + + Select + + + Select + + + + + + + + + + + + + + + + + + diff --git a/row_format/dynamic/insert.lua b/row_format/dynamic/insert.lua new file mode 100755 index 0000000..511578b --- /dev/null +++ b/row_format/dynamic/insert.lua @@ -0,0 +1,56 @@ +#!/usr/bin/env sysbench + +local c_value_template = "###########-###########-###########-" .. + "###########-###########-###########-" .. + "###########-###########-###########-" .. + "###########" + +function prepare() + local drv = sysbench.sql.driver() + local con = drv:connect() + + con:query(string.format([[ + CREATE TABLE IF NOT EXISTS sbtest ( + id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, + c VARCHAR(120) DEFAULT '' NOT NULL, + PRIMARY KEY (id) + ) ENGINE=InnoDB ROW_FORMAT=DYNAMIC + ]])) +end + +function cleanup() + local drv = sysbench.sql.driver() + local con = drv:connect() + + con:query("DROP TABLE IF EXISTS sbtest") +end + +function thread_init() + drv = sysbench.sql.driver() + con = drv:connect() +end + +function get_c_value() + return sysbench.rand.string(c_value_template) +end + +function event () + query = string.format("INSERT INTO sbtest (c) VALUES ('%s')", get_c_value()) + + con:query(query) +end + +function thread_done() + con:disconnect() +end + +function sysbench.hooks.report_intermediate(stat) + drv = sysbench.sql.driver() + con = drv:connect() + + print(string.format("%.0f;%d", + stat.time_total, + stat.events + )) +end + diff --git a/row_format/dynamic/select.lua b/row_format/dynamic/select.lua new file mode 100755 index 0000000..dc7a88b --- /dev/null +++ b/row_format/dynamic/select.lua @@ -0,0 +1,33 @@ +#!/usr/bin/env sysbench + +function thread_init() + drv = sysbench.sql.driver() + con = drv:connect() +end + +function event () + -- Maybe to optimize the second arg on math.random(1, 460000) + -- is good to take first select max(id) from sbtest; and round. + -- + local rnd = math.random(1, 460000) + local sql = [[ + SELECT SQL_NO_CACHE * + FROM sbtest + WHERE id = %d + ]] + + con:query(string.format(sql, rnd)) +end + +function thread_done() + con:disconnect() +end + +function sysbench.hooks.report_intermediate(stat) + local seconds = stat.time_interval + + print(string.format("%.0f;%d", + stat.time_total, + stat.events + )) +end