You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

27 lines
707 B

#!/usr/bin/sysbench
require("account_common")
-- 初始化数据库 第一个调用的lua函数
function thread_init()
print("thread_init ID:" .. thread_id .. " max:" .. sysbench.opt.threads)
drv = sysbench.sql.driver()
con = drv:connect()
end
function thread_done()
print("thread_done ID:" .. thread_id)
con:disconnect()
end
function select_one_account()
local one_thread_count = account_table_max / sysbench.opt.threads;
local db_index = thread_id * one_thread_count + sysbench.rand.default(1, one_thread_count);
local account_id = sysbench.rand.default(1, 5000)
con:query(select_account(db_index, account_id));
end
function event()
select_one_account();
end