From d46a4a10b37c30d71f2c42fcb630c4f26fcdf81a Mon Sep 17 00:00:00 2001 From: lmatz Date: Thu, 19 Oct 2023 17:07:49 +0800 Subject: [PATCH] add a simple limit 10 select --- README.md | 22 +++++++++++++++ src/lua/Makefile.am | 3 +- src/lua/select_random_limits.lua | 47 ++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 src/lua/select_random_limits.lua diff --git a/README.md b/README.md index b460f71c3..f6589da78 100644 --- a/README.md +++ b/README.md @@ -451,6 +451,28 @@ sysbench \ run ``` +### select_random_limits.lua +``` +sysbench \ +--db-driver=pgsql \ +--pgsql-host=localhost \ +--pgsql-port=4566 \ +--pgsql-user=root \ +--pgsql-db=dev \ +--threads=16 \ +--report-interval=1 \ +--events=0 \ +--time=10 \ +--percentile=99 \ +--auto_inc=false \ +--table_size=1000000 \ +--db-ps-mode=disable \ +--skip_trx=true \ +--range_size=1 \ +/usr/local/share/sysbench/select_random_limits.lua \ +run +``` + ## CleanUp ``` sysbench \ diff --git a/src/lua/Makefile.am b/src/lua/Makefile.am index c8b7af429..7d331b095 100644 --- a/src/lua/Makefile.am +++ b/src/lua/Makefile.am @@ -26,6 +26,7 @@ dist_pkgdata_SCRIPTS = bulk_insert.lua \ oltp_update_non_index.lua \ oltp_write_only.lua\ select_random_points.lua \ - select_random_ranges.lua + select_random_ranges.lua \ + select_random_limits.lua dist_pkgdata_DATA = oltp_common.lua diff --git a/src/lua/select_random_limits.lua b/src/lua/select_random_limits.lua new file mode 100644 index 000000000..ef373602c --- /dev/null +++ b/src/lua/select_random_limits.lua @@ -0,0 +1,47 @@ +#!/usr/bin/env sysbench + +require("oltp_common") + +-- Override standard prepare/cleanup OLTP functions, as this benchmark does not +-- support multiple tables +oltp_prepare = prepare +oltp_cleanup = cleanup + +function prepare() + assert(sysbench.opt.tables == 1, "this benchmark does not support " .. + "--tables > 1") + oltp_prepare() +end + +function cleanup() + assert(sysbench.opt.tables == 1, "this benchmark does not support " .. + "--tables > 1") + oltp_cleanup() +end + +function thread_init() + drv = sysbench.sql.driver() + con = drv:connect() + + local limit = "10" + + stmt = con:prepare(string.format([[ + SELECT * + FROM sbtest1 + LIMIT %s]], limit)) + + rlen = sysbench.opt.table_size / sysbench.opt.threads + + thread_id = sysbench.tid % sysbench.opt.threads +end + +function thread_done() + stmt:close() + con:disconnect() +end + +function event() + stmt:execute() + + check_reconnect() +end