33
33
sysbench .cmdline .options = {
34
34
table_size =
35
35
{" Number of rows per table" , 10000 },
36
+ start_id =
37
+ {" Start id of rows for prepare insert into table, " ..
38
+ " used for parallel prepare data into one table, " ..
39
+ " users can run multiple sysbench process with different start_id concurrently. " ..
40
+ " in this case, range_size is the number of rows to be inserted, id of inserted " ..
41
+ " rows are {start_id, start_id + 1, ..., start_id + range_size - 1}. " ..
42
+ " this option should not be used with auto_inc. " ..
43
+ " default is 0 to conform origin sysbench" , 0 },
36
44
range_size =
37
45
{" Range size for range SELECT queries" , 100 },
38
46
tables =
@@ -198,7 +206,7 @@ function create_table(drv, con, table_num)
198
206
199
207
if sysbench .opt .use_file then
200
208
query = string.format ([[
201
- CREATE TABLE sbtest%d(
209
+ CREATE TABLE IF NOT EXISTS sbtest%d(
202
210
id %s,
203
211
k INTEGER DEFAULT '0' NOT NULL,
204
212
c VARCHAR(512) DEFAULT '' NOT NULL,
@@ -209,7 +217,7 @@ function create_table(drv, con, table_num)
209
217
sysbench .opt .create_table_options )
210
218
else
211
219
query = string.format ([[
212
- CREATE TABLE sbtest%d(
220
+ CREATE TABLE IF NOT EXISTS sbtest%d(
213
221
id %s,
214
222
k INTEGER DEFAULT '0' NOT NULL,
215
223
c CHAR(120) DEFAULT '' NOT NULL,
@@ -237,8 +245,18 @@ function create_table(drv, con, table_num)
237
245
238
246
local c_val
239
247
local pad_val
248
+ local start_id ;
249
+ local finish_id ;
240
250
241
- for i = 1 , sysbench .opt .table_size do
251
+ if sysbench .opt .start_id == 0 then
252
+ start_id = 1 ;
253
+ finish_id = sysbench .opt .table_size ;
254
+ else
255
+ start_id = sysbench .opt .start_id ;
256
+ finish_id = start_id + sysbench .opt .range_size - 1 ;
257
+ end
258
+
259
+ for i = start_id , finish_id do
242
260
243
261
if sysbench .opt .use_file then
244
262
c_val , pad_val = get_str_value ()
0 commit comments