diff options
author | Igor Babaev <igor@askmonty.org> | 2022-10-18 17:19:21 -0700 |
---|---|---|
committer | Igor Babaev <igor@askmonty.org> | 2022-10-18 17:19:21 -0700 |
commit | 3ea7b07c94745839403de5669b22b654b97b30a8 (patch) | |
tree | 25f6a8cddcae925e7db5f1cdf312e17430e453d1 /sql/sql_update.cc | |
parent | 4100aac0bd14e25c79339b3e23e6d1022b4e8d50 (diff) | |
download | mariadb-git-bb-10.11-igor.tar.gz |
MDEV-7487 Semi-join optimization for single-table update/delete statementsbb-10.11-igor
This patch allows to use semi-join optimization at the top level of
single-table update and delete statements.
The problem of supporting such optimization became easy to resolve after
processing a single-table update/delete statement started using JOIN
structure. This allowed to use JOIN::prepare() not only for multi-table
updates/deletes but for single-table ones as well. This was done in the
patch for mdev-28883:
Re-design the upper level of handling UPDATE and DELETE statements.
Note that JOIN::prepare() detects all subqueries that can be considered
as candidates for semi-join optimization. The code added by this patch
looks for such candidates at the top level and if such candidates are found
in the processed single-table update/delete the statement is handled in
the same way as a multi-table update/delete.
Approved by Oleksandr Byelkin <sanja@mariadb.com>
Diffstat (limited to 'sql/sql_update.cc')
-rw-r--r-- | sql/sql_update.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 6e54e664152..22e08fc0784 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -2476,6 +2476,8 @@ int multi_update::do_updates() table = cur_table->table; if (table == table_to_update) continue; // Already updated + if (table->file->pushed_rowid_filter) + table->file->disable_pushed_rowid_filter(); org_updated= updated; tmp_table= tmp_tables[cur_table->shared]; tmp_table->file->extra(HA_EXTRA_CACHE); // Change to read cache @@ -2670,7 +2672,8 @@ int multi_update::do_updates() check_opt_it.rewind(); while (TABLE *tbl= check_opt_it++) tbl->file->ha_rnd_end(); - + if (table->file->save_pushed_rowid_filter) + table->file->enable_pushed_rowid_filter(); } DBUG_RETURN(0); @@ -2681,6 +2684,8 @@ err: } err2: + if (table->file->save_pushed_rowid_filter) + table->file->enable_pushed_rowid_filter(); if (table->file->inited) (void) table->file->ha_rnd_end(); if (tmp_table->file->inited) @@ -2984,7 +2989,9 @@ bool Sql_cmd_update::prepare_inner(THD *thd) { goto err; } - + if (!multitable && + select_lex->sj_subselects.elements) + multitable= true; } if (table_list->has_period()) |