summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2022-04-05 20:12:29 +0300
committerSergei Petrunia <sergey@mariadb.com>2023-02-02 21:44:00 +0300
commit5e651c9aea1234c7ee83c38761af251872960335 (patch)
tree029f20adfa664e0d6a749f71dd4d5e048456a0f6 /sql/table.cc
parentb6215b9b20b55911ca06c4cee1fa6ebdd4e8e1eb (diff)
downloadmariadb-git-5e651c9aea1234c7ee83c38761af251872960335.tar.gz
Make the most important optimizer constants user variables
Variables added: - optimizer_index_block_copy_cost - optimizer_key_copy_cost - optimizer_key_next_find_cost - optimizer_key_compare_cost - optimizer_row_copy_cost - optimizer_where_compare_cost Some rename of defines was done to make the internal defines similar to the visible ones: TIME_FOR_COMPARE -> WHERE_COST; WHERE_COST was also "inverted" to be a number between 0 and 1 that is multiply with accepted records (similar to other optimizer variables). TIME_FOR_COMPARE_IDX -> KEY_COMPARE_COST. This is also inverted, similar to TIME_FOR_COMPARE. TIME_FOR_COMPARE_ROWID -> ROWID_COMPARE_COST. This is also inverted, similar to TIME_FOR_COMPARE. All default costs are identical to what they where before this patch. Other things: - Compare factor in get_merge_buffers_cost() was inverted. - Changed namespace to static in filesort_utils.cc
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc18
1 files changed, 14 insertions, 4 deletions
diff --git a/sql/table.cc b/sql/table.cc
index 17611a1e2fb..16dcb48970d 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -5672,12 +5672,14 @@ void TABLE::init(THD *thd, TABLE_LIST *tl)
opt_range_condition_rows=0;
no_cache= false;
initialize_opt_range_structures();
+
+
/*
- Update optimizer_cache_cost to ensure that a SET STATEMENT of
- the variable it will work.
+ Update optimizer_costs to ensure that a SET STATEMENT of the
+ variables it will work.
*/
- file->set_optimizer_cache_cost(cache_hit_cost(thd->variables.
- optimizer_cache_hit_ratio));
+ file->set_optimizer_costs(thd);
+
#ifdef HAVE_REPLICATION
/* used in RBR Triggers */
master_had_triggers= 0;
@@ -10434,6 +10436,14 @@ inline void TABLE::initialize_opt_range_structures()
TRASH_ALLOC(const_key_parts, s->keys * sizeof(*const_key_parts));
}
+
+double TABLE::OPT_RANGE::index_only_fetch_cost(THD *thd)
+{
+ return (index_only_cost + (double) rows *
+ thd->variables.optimizer_key_copy_cost);
+}
+
+
/*
Mark table to be reopened after query
*/