Skip to content
Permalink
Browse files

PS-5783: New thread variables: innodb_(force_index_)records_in_range

  • Loading branch information...
dutow committed Aug 5, 2019
1 parent 415d8a6 commit 677aa7c8aa64ca0aca25c07813e48309e5f06109
Showing with 37 additions and 0 deletions.
  1. +22 −0 storage/innobase/handler/ha_innodb.cc
  2. +15 −0 storage/innobase/handler/ha_innopart.cc
@@ -636,6 +636,26 @@ uint get_global_default_encryption_key_id_value()
return THDVAR(NULL, default_encryption_key_id);
}

static MYSQL_THDVAR_UINT(records_in_range, PLUGIN_VAR_RQCMDARG,
"Used to override the result of records_in_range(). "
"Set to a positive number to override",
NULL, NULL, 0,
/* min */ 0, /* max */ INT_MAX, 0);

static MYSQL_THDVAR_UINT(force_index_records_in_range, PLUGIN_VAR_RQCMDARG,
"Used to override the result of records_in_range() "
"when FORCE INDEX is used.",
NULL, NULL, 0,
/* min */ 0, /* max */ INT_MAX, 0);

uint innodb_force_index_records_in_range(THD* thd) {
return THDVAR(thd, force_index_records_in_range);
}

uint innodb_records_in_range(THD* thd) {
return THDVAR(thd, records_in_range);
}

/** Set up InnoDB API callback function array */
ib_cb_t innodb_api_cb[] = {
(ib_cb_t) ib_cursor_open_table,
MYSQL_SYSVAR(background_scrub_data_compressed),
MYSQL_SYSVAR(background_scrub_data_interval),
MYSQL_SYSVAR(background_scrub_data_check_interval),
MYSQL_SYSVAR(records_in_range),
MYSQL_SYSVAR(force_index_records_in_range),
NULL
};

@@ -3278,6 +3278,9 @@ ha_innopart::records(
}
#endif

uint innodb_force_index_records_in_range(THD* thd);
uint innodb_records_in_range(THD* thd);

/** Estimates the number of index records in a range.
@param[in] keynr Index number.
@param[in] min_key Start key value (or NULL).
@@ -3302,6 +3305,18 @@ ha_innopart::records_in_range(
DBUG_ENTER("ha_innopart::records_in_range");
DBUG_PRINT("info", ("keynr %u min %p max %p", keynr, min_key, max_key));

const ha_rows ret = innodb_records_in_range(ha_thd());
if (ret) {
DBUG_RETURN(ret);
}

if (table->force_index) {
const ha_rows force_rows = innodb_force_index_records_in_range(ha_thd());
if (force_rows) {
DBUG_RETURN(force_rows);
}
}

ut_a(m_prebuilt->trx == thd_to_trx(ha_thd()));

m_prebuilt->trx->op_info = (char*)"estimating records in index range";

0 comments on commit 677aa7c

Please sign in to comment.
You can’t perform that action at this time.