Add --oltp-secondary option to use a secondary index on _id_ rather than a primary key.

Add --oltp-point-select-all-cols to make the point-select query (fetch 1 row by primary key)
fetch all columns from the row rather than only _c_. This makes it comparable to the work
done when --oltp-point-select-mysql-handler is used because HANDLER statements fetch all
columns.
This commit is contained in:
Mark Callaghan
2009-09-30 15:44:21 -07:00
parent 9794383fca
commit d9b13b92b2

View File

@ -76,6 +76,8 @@ static sb_arg_t oltp_args[] =
{"oltp-dist-res", "percentage of 'special' values to use (for special distribution)",
SB_ARG_TYPE_INT, "75"},
{"oltp-point-select-mysql-handler", "Use MySQL HANDLER for point select", SB_ARG_TYPE_FLAG, "off"},
{"oltp-point-select-all-cols", "select all columns for the point-select query", SB_ARG_TYPE_FLAG, "off"},
{"oltp-secondary", "Use a secondary index in place of the PRIMARY index", SB_ARG_TYPE_FLAG, "off"},
{NULL, NULL, SB_ARG_TYPE_NULL, NULL}
};
@ -145,6 +147,8 @@ typedef struct
unsigned int dist_pct;
unsigned int dist_res;
unsigned int point_select_mysql_handler;
unsigned int point_select_all_cols;
unsigned int secondary;
} oltp_args_t;
/* Test statements structure */
@ -375,13 +379,14 @@ int oltp_cmd_prepare(void)
"k integer %s DEFAULT '0' NOT NULL, "
"c char(120) DEFAULT '' NOT NULL, "
"pad char(60) DEFAULT '' NOT NULL, "
"PRIMARY KEY (id) "
"%s (id) "
") %s",
args.table_name,
(args.auto_inc && driver_caps.serial) ? "SERIAL" : "INTEGER",
driver_caps.unsigned_int ? "UNSIGNED" : "",
(args.auto_inc && driver_caps.auto_increment) ? "AUTO_INCREMENT" : "",
driver_caps.unsigned_int ? "UNSIGNED" : "",
args.secondary ? "KEY xid" : "PRIMARY KEY",
(table_options_str != NULL) ? table_options_str : ""
);
if (db_query(con, query) == NULL)
@ -1565,6 +1570,14 @@ int parse_arguments(void)
}
args.point_select_mysql_handler = sb_get_value_flag("oltp-point-select-mysql-handler");
args.point_select_all_cols = sb_get_value_flag("oltp-point-select-all-cols");
args.secondary = sb_get_value_flag("oltp-secondary");
if (args.auto_inc && args.secondary)
{
log_text(LOG_FATAL, "Cannot set both --oltp-auto-inc and --oltp-secondary");
return 1;
}
return 0;
}
@ -1675,13 +1688,22 @@ int prepare_stmt_set_trx(oltp_stmt_set_t *set, oltp_bind_set_t *bufs, db_conn_t
return 1;
}
snprintf(query, MAX_QUERY_LEN, "HANDLER %s READ `PRIMARY` = (?)",
args.table_name);
snprintf(query, MAX_QUERY_LEN, "HANDLER %s READ `%s` = (?)",
args.table_name,
args.secondary ? "xid" : "PRIMARY");
}
else
{
snprintf(query, MAX_QUERY_LEN, "SELECT c from %s where id=?",
args.table_name);
if (args.point_select_all_cols)
{
snprintf(query, MAX_QUERY_LEN, "SELECT id, k, c, pad from %s where id=?",
args.table_name);
}
else
{
snprintf(query, MAX_QUERY_LEN, "SELECT c from %s where id=?",
args.table_name);
}
}
set->point = db_prepare(conn, query);
if (set->point == NULL)