From ae295825efda5626f1d724e27e885d46ba20b6ef Mon Sep 17 00:00:00 2001 From: pfriedenbach Date: Wed, 3 Feb 2016 12:15:31 -0800 Subject: [PATCH 1/5] Update oltp.lua Added new controls around range select operations (oltp_range_selects) and delete/insert operations (oltp_delete_inserts). --- sysbench/tests/db/oltp.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sysbench/tests/db/oltp.lua b/sysbench/tests/db/oltp.lua index c72cf69..e5f8ee6 100644 --- a/sysbench/tests/db/oltp.lua +++ b/sysbench/tests/db/oltp.lua @@ -18,6 +18,7 @@ end function event(thread_id) local rs local i + local idx local table_name local range_start local c_val @@ -33,6 +34,8 @@ function event(thread_id) rs = db_query("SELECT c FROM ".. table_name .." WHERE id=" .. sb_rand(1, oltp_table_size)) end + if oltp_range_selects then + for i=1, oltp_simple_ranges do range_start = sb_rand(1, oltp_table_size) rs = db_query("SELECT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1) @@ -53,6 +56,8 @@ function event(thread_id) rs = db_query("SELECT DISTINCT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1 .. " ORDER BY c") end + end + if not oltp_read_only then for i=1, oltp_index_updates do @@ -68,7 +73,9 @@ function event(thread_id) end end - i = sb_rand(1, oltp_table_size) + for idx=1, oltp_delete_inserts do + + idx = sb_rand(1, oltp_table_size) rs = db_query("DELETE FROM " .. table_name .. " WHERE id=" .. i) @@ -79,6 +86,8 @@ function event(thread_id) rs = db_query("INSERT INTO " .. table_name .. " (id, k, c, pad) VALUES " .. string.format("(%d, %d, '%s', '%s')",i, sb_rand(1, oltp_table_size) , c_val, pad_val)) + end + end -- oltp_read_only if not oltp_skip_trx then From 7ec8a14c5ee4cd13afc2cdbcaf65abfd157d2d09 Mon Sep 17 00:00:00 2001 From: pfriedenbach Date: Wed, 3 Feb 2016 12:18:36 -0800 Subject: [PATCH 2/5] Update common.lua Add control defaults for oltp_delete_inserts and oltp_range_selects. --- sysbench/tests/db/common.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sysbench/tests/db/common.lua b/sysbench/tests/db/common.lua index 6aabecd..6cfc62e 100644 --- a/sysbench/tests/db/common.lua +++ b/sysbench/tests/db/common.lua @@ -132,7 +132,14 @@ function set_vars() oltp_distinct_ranges = oltp_distinct_ranges or 1 oltp_index_updates = oltp_index_updates or 1 oltp_non_index_updates = oltp_non_index_updates or 1 + oltp_delete_inserts = oltp_delete_inserts or 1 + if (oltp_range_selets = 'off') then + oltp_range_selects = false + else + oltp_range_selects = true + end + if (oltp_auto_inc == 'off') then oltp_auto_inc = false else From 0accfd720625c80c968e49987cd30f3ae6b9da60 Mon Sep 17 00:00:00 2001 From: pfriedenbach Date: Wed, 3 Feb 2016 12:21:41 -0800 Subject: [PATCH 3/5] Update oltp.lua --- sysbench/tests/db/oltp.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysbench/tests/db/oltp.lua b/sysbench/tests/db/oltp.lua index e5f8ee6..6edfc9d 100644 --- a/sysbench/tests/db/oltp.lua +++ b/sysbench/tests/db/oltp.lua @@ -75,7 +75,7 @@ function event(thread_id) for idx=1, oltp_delete_inserts do - idx = sb_rand(1, oltp_table_size) + i = sb_rand(1, oltp_table_size) rs = db_query("DELETE FROM " .. table_name .. " WHERE id=" .. i) From 7a37c6467adc7c4f67000c36c364ef43fd99be7f Mon Sep 17 00:00:00 2001 From: pfriedenbach Date: Thu, 1 Sep 2016 11:26:06 -0700 Subject: [PATCH 4/5] Added oltp-write-only control Added oltp-write-only : Specifies a test to consist of write only statements (insert, update, and deletes). --- sysbench/tests/db/common.lua | 14 ++++++++++---- sysbench/tests/db/oltp.lua | 11 +++++++---- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/sysbench/tests/db/common.lua b/sysbench/tests/db/common.lua index 6cfc62e..85c240c 100644 --- a/sysbench/tests/db/common.lua +++ b/sysbench/tests/db/common.lua @@ -134,12 +134,12 @@ function set_vars() oltp_non_index_updates = oltp_non_index_updates or 1 oltp_delete_inserts = oltp_delete_inserts or 1 - if (oltp_range_selets = 'off') then - oltp_range_selects = false + if (oltp_range_selects == 'off') then + oltp_range_selects = false else - oltp_range_selects = true + oltp_range_selects = true end - + if (oltp_auto_inc == 'off') then oltp_auto_inc = false else @@ -152,6 +152,12 @@ function set_vars() oltp_read_only = false end + if (oltp_write_only == 'on') then + oltp_write_only = true + else + oltp_write_only = false + end + if (oltp_skip_trx == 'on') then oltp_skip_trx = true else diff --git a/sysbench/tests/db/oltp.lua b/sysbench/tests/db/oltp.lua index 6edfc9d..985ca0c 100644 --- a/sysbench/tests/db/oltp.lua +++ b/sysbench/tests/db/oltp.lua @@ -18,7 +18,6 @@ end function event(thread_id) local rs local i - local idx local table_name local range_start local c_val @@ -30,12 +29,14 @@ function event(thread_id) db_query(begin_query) end + if not oltp_write_only then + for i=1, oltp_point_selects do rs = db_query("SELECT c FROM ".. table_name .." WHERE id=" .. sb_rand(1, oltp_table_size)) end if oltp_range_selects then - + for i=1, oltp_simple_ranges do range_start = sb_rand(1, oltp_table_size) rs = db_query("SELECT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1) @@ -58,6 +59,8 @@ function event(thread_id) end + end + if not oltp_read_only then for i=1, oltp_index_updates do @@ -73,8 +76,8 @@ function event(thread_id) end end - for idx=1, oltp_delete_inserts do - + for i=1, oltp_delete_inserts do + i = sb_rand(1, oltp_table_size) rs = db_query("DELETE FROM " .. table_name .. " WHERE id=" .. i) From cbd1417cbae7b099f5db9b0d05f40482b943c0c9 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Sat, 3 Sep 2016 14:47:17 +0300 Subject: [PATCH 5/5] Make --oltp-read-only=on and --oltp-write-only=on mutually exclusive. --- sysbench/tests/db/common.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sysbench/tests/db/common.lua b/sysbench/tests/db/common.lua index 78db9dc..f9c0e19 100644 --- a/sysbench/tests/db/common.lua +++ b/sysbench/tests/db/common.lua @@ -158,6 +158,10 @@ function set_vars() oltp_write_only = false end + if (oltp_read_only and oltp_write_only) then + error("--oltp-read-only and --oltp-write-only are mutually exclusive") + end + if (oltp_skip_trx == 'on') then oltp_skip_trx = true else