Skip to content

Commit

Permalink
Merge pull request #4 from risingwavelabs/lz/select_limit_10
Browse files Browse the repository at this point in the history
add a simple limit 10 select
  • Loading branch information
lmatz authored Oct 19, 2023
2 parents 0c7d3ba + d46a4a1 commit 1fa78cf
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
3 changes: 2 additions & 1 deletion src/lua/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
47 changes: 47 additions & 0 deletions src/lua/select_random_limits.lua
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 1fa78cf

Please sign in to comment.