summaryrefslogtreecommitdiff
path: root/sql/opt_subselect.cc
Commit message (Collapse)AuthorAgeFilesLines
* Merge 10.3 into 10.4Marko Mäkelä2020-12-011-2/+6
|\
| * MDEV-21265: IN predicate conversion to IN subquery should be allowed for a ↵Varun Gupta2020-11-301-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | broader set of datatype comparison Allow materialization strategy when collations on the inner and outer sides of an IN subquery are the same and the character set of the inner side is a proper subset of the character set on the outer side. This allows conversion from utf8mb3 to utf8mb4 as the former is a subset of the later. This is only allowed when IN predicate is converted to an IN subquery Backported part of the patch (d6a00d9b18f) of MDEV-17905.
* | Merge branch '10.3' into 10.4Sujatha2020-09-281-9/+4
|\ \ | |/
| * Merge branch '10.2' into 10.3Sujatha2020-09-281-9/+4
| |\
| | * Fix GCC 10.2.0 -Og -fsanitize=undefined -Wmaybe-uninitializedMarko Mäkelä2020-09-231-9/+4
| | | | | | | | | | | | | | | | | | For some reason, adding -fsanitize=undefined (cmake -DWITH_UBSAN=ON) to the compilation flags will cause even more warnings to be emitted. The warnings do look bogus, but the code can be simplified.
* | | Merge 10.3 into 10.4Marko Mäkelä2020-07-151-3/+2
|\ \ \ | |/ /
| * | Merge 10.2 into 10.3Marko Mäkelä2020-07-141-3/+2
| |\ \ | | |/
| | * MDEV-22058: Assertion `!is_set() || (m_status == DA_OK_BULK && ↵Rucha Deodhar2020-07-121-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | is_bulk_op())' failed in Diagnostics_area::set_ok_status Error state is not stored in check_and_do_in_subquery_rewrites() when there is illegal combination of optimizer switches. So all the functions eventually return false. Thus the assetion failure.
* | | Improved speed of optimizer traceMonty2020-03-091-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Added unlikely() to optimize for not having optimizer trace enabled - Made THD::trace_started() inline - Added 'if (trace_enabled())' around some potentially expensive code (not many found) - Added ASSERT's to ensure we don't call expensive optimizer trace calls if optimizer trace is not enabled - Added length to Json_writer functions to speed up buffer writes when optimizer trace is enabled. - Changed LEX_CSTRING argument handling to not send full struct to writer function on_add_str() functions now trusts length arguments
* | | Merge 10.3 into 10.4Marko Mäkelä2019-12-131-1/+6
|\ \ \ | |/ / | | | | | | | | | We disable the MDEV-21189 test galera.galera_partition because it times out.
| * | MDEV-20900: IN predicate to IN subquery conversion causes performance regressionVarun Gupta2019-12-101-1/+6
| | | | | | | | | | | | | | | Disable the IN predicate to IN subquery conversion when the types on the left and right hand side of the IN predicate are not of comparable type.
* | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-12-091-1/+1
|\ \ \ | |/ /
| * | Lintian complains on spelling errorFaustin Lammler2019-12-021-1/+1
| | | | | | | | | | | | | | | The lintian check complains on spelling error: https://salsa.debian.org/mariadb-team/mariadb-10.3/-/jobs/95739
* | | Merge 10.3 into 10.4Marko Mäkelä2019-11-141-1/+16
|\ \ \ | |/ /
| * | MDEV-20646: 10.3.18 is slower than 10.3.17Sergei Petrunia2019-11-131-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix incorrect change introduced in the fix for MDEV-20109. The patch tried to compute a more precise estimate for the record_count value in SJ-Materialization-Scan strategy (in Sj_materialization_picker::check_qep). However the new formula is worse as it produces extremely optimistic results in common cases where SJ-Materialization-Scan should be used) The old formula produces pessimistic results in cases when Sj-Materialization- Scan is unlikely to be a good choice anyway. So, the old behavior is better.
* | | Merge 10.3 into 10.4Marko Mäkelä2019-11-011-2/+10
|\ \ \ | |/ /
| * | Merge branch '10.2' into 10.3Oleksandr Byelkin2019-10-311-2/+10
| |\ \ | | |/
| | * Merge 10.1 into 10.2Marko Mäkelä2019-10-251-2/+10
| | |\
| | | * Merge branch 'github/5.5' into 10.1Sergei Golubchik2019-10-231-2/+10
| | | |\
| | | | * MDEV-13172: Wrong result / SELECT ... WHERE EXISTS ... (with UNIQUE Key)bb-5.5-MDEV-13172Oleksandr Byelkin2019-10-151-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | IS NULL or <=> with unique field does not mean unique row, because several NULL possible, so we can not convert to normal join in this case.
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-09-231-10/+17
|\ \ \ \ \ | |/ / / / | | | | | | | | | | Disable MDEV-20576 assertions until MDEV-20595 has been fixed.
| * | | | Merge 10.2 into 10.3Marko Mäkelä2019-09-231-10/+16
| |\ \ \ \ | | |/ / /
| | * | | MDEV-20371: Invalid reads at plan refinement stage: join->positions...Sergei Petrunia2019-09-111-10/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | best_access_path() is called from two optimization phases: 1. Plan choice phase, in choose_plan(). Here, the join prefix being considered is in join->positions[] 2. Plan refinement stage, in fix_semijoin_strategies_for_picked_join_order Here, the join prefix is in join->best_positions[] It used to access join->positions[] from stage #2. This didnt cause any valgrind or asan failures (as join->positions[] has been written-to before) but the effect was similar to that of reading the random data: The join prefix we've picked (in join->best_positions) could have nothing in common with the join prefix that was last to be considered (in join->positions).
* | | | | MDEV-20440: Optimizer trace: print more details about semi-join optimizationSergei Petrunia2019-09-121-3/+5
| | | | | | | | | | | | | | | | | | | | Followup patch: fix typos
* | | | | Moved the function trace_plan_prefix to the optimizer trace fileVarun Gupta2019-09-111-2/+1
| | | | | | | | | | | | | | | | | | | | Also added comments for trace_plan_prefix and the class Json_writer_temp_disable
* | | | | Fixed a typoVarun Gupta2019-09-021-1/+1
| | | | |
* | | | | Followup fix for MDEV-20440Varun Gupta2019-09-021-0/+3
| | | | |
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-08-311-2/+5
|\ \ \ \ \ | |/ / / /
| * | | | MDEV-20109: Optimizer ignores distinct key created for materialized...Sergei Petrunia2019-08-301-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (Backported to 10.3, addressed review input) Sj_materialization_picker::check_qep(): fix error in cost/fanout calculations: - for each join prefix, add #prefix_rows / TIME_FOR_COMPARE to the cost, like best_extension_by_limited_search does - Remove the fanout produced by the subquery tables. - Also take into account join condition selectivity optimize_wo_join_buffering() (used by LooseScan and FirstMatch) - also add #prefix_rows / TIME_FOR_COMPARE to the cost of each prefix. - Also take into account join condition selectivity
* | | | | MDEV-6111: Optimizer Trace: add tracing for semi-join optimizationsSergei Petrunia2019-08-251-17/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added: - "semijoin_strategy_choice" element (actions in advance_sj_state(), name matches the name in MySQL) - semijoin_table_pullout element.
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-05-291-30/+43
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.2 into 10.3Marko Mäkelä2019-05-291-30/+43
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.1 into 10.2Marko Mäkelä2019-05-281-30/+43
| | |\ \ \ | | | |/ /
| | | * | Merge 5.5 into 10.1Marko Mäkelä2019-05-281-30/+43
| | | |\ \ | | | | |/
| | | | * MDEV-18479 Assertion `join->best_read < double(1.79769313486231570815e+308L)'Igor Babaev2019-05-271-28/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | or server crashes in JOIN::fix_all_splittings_in_plan after EXPLAIN This patch resolves the problem of overflowing when performing calculations to estimate the cost of an evaluated query execution plan. The overflowing in a non-debug build could cause different kind of problems uncluding crashes of the server.
| | | | * MDEV-18896 Crash in convert_join_subqueries_to_semijoins : CorrectionIgor Babaev2019-05-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch complements the original patch for MDEV-18896 that prevents conversions to semi-joins in tableless selects used in INSERT statements in post-5.5 versions of the server. The test case was corrected as well to ensure that potential conversion to jtbm semi-joins is also checked (the problem was that one of the preceeding testcases in subselect_sj.test did not restore the state of the optimizer switch leaving the 'materialization' in the state 'off' and so blocking this check). Noticed an inconsistency in the state of select_lex::table_list used in INSERT statements and left a comment about this.
* | | | | Merge branch '10.3' into 10.4Oleksandr Byelkin2019-05-191-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge 10.2 into 10.3Marko Mäkelä2019-05-141-1/+1
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.1 into 10.2Marko Mäkelä2019-05-131-1/+1
| | |\ \ \ | | | |/ /
| | | * | Merge branch '5.5' into 10.1Vicențiu Ciorbaru2019-05-111-1/+1
| | | |\ \ | | | | |/
| | | | * Update FSF addressMichal Schorm2019-05-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit is based on the work of Michal Schorm, rebased on the earliest MariaDB version. Th command line used to generate this diff was: find ./ -type f \ -exec sed -i -e 's/Foundation, Inc., 59 Temple Place, Suite 330, Boston, /Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, /g' {} \; \ -exec sed -i -e 's/Foundation, Inc. 59 Temple Place.* Suite 330, Boston, /Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, /g' {} \; \ -exec sed -i -e 's/MA.*.....-1307.*USA/MA 02110-1335 USA/g' {} \; \ -exec sed -i -e 's/Foundation, Inc., 59 Temple/Foundation, Inc., 51 Franklin/g' {} \; \ -exec sed -i -e 's/Place, Suite 330, Boston, MA.*02111-1307.*USA/Street, Fifth Floor, Boston, MA 02110-1335 USA/g' {} \; \ -exec sed -i -e 's/MA.*.....-1307/MA 02110-1335/g' {} \;
* | | | | MDEV-19134: EXISTS() slower if ORDER BY is definedSergei Petrunia2019-05-161-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Step 1: Removal of ORDER BY [LIMIT] from the subquery should be done earlier and for broader class of subqueries. The rewrite was done in Item_in_subselect::select_in_like_transformer(), but this had problems: - It didn't cover EXISTS subqueries - It covered IN-subqueries, but was done after the semi-join transformation was considered inapplicable, because ORDER BY was present. Remaining issue: - EXISTS->IN transformation happens before check_and_do_in_subquery_rewrites() is called, so it is still prevented by the present ORDER BY.
* | | | | MDEV-19235 MariaDB Server compiled for 128 Indexes crashes at startupbb-10.4-wlad-MDEV-19235Vladislav Vaintroub2019-05-091-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With MAX_INDEXIES=64(default), key_map=Bitmap<64> is just a wrapper around ulonglong and thus "trivial" (can be bzero-ed, or memcpy-ed, and stays valid still) With MAX_INDEXES=128, key_map = Bitmap<128> is not a "trivial" type anymore. The implementation uses MY_BITMAP, and MY_BITMAP contains pointers which make Bitmap invalid, when it is memcpy-ed/bzero-ed. The problem in 10.4 is that there are many new key_map members, inside TABLE or KEY, and those are often memcopied and bzeroed The fix makes Bitmap "trivial", by inlining most of MY_BITMAP functionality. pointers/heap allocations are not used anymore.
* | | | | MDEV-19245: Impossible WHERE should be noticed earlier after HAVING pushdownbb-10.4-galinaGalina Shalygina2019-04-221-12/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bug appears because not all conditions are found to be knowingly true or false in WHERE after HAVING pushdown optimization. Impossible WHERE can be found much earlier compared with how it is done now. To fix it and_new_conditions_to_optimized_cond() is changed.
* | | | | MDEV-18769 Assertion `fixed == 1' failed in Item_cond_or::val_intGalina Shalygina2019-04-041-98/+176
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This bug is caused by pushdown from HAVING into WHERE. It appears because condition that is pushed wasn't fixed. It is also discovered that condition pushdown from HAVING into WHERE is done wrong. There is no need to build clones for some conditions that can be pushed. They can be simply moved from HAVING into WHERE without cloning. build_pushable_cond_for_having_pushdown(), remove_pushed_top_conjuncts_for_having() methods are changed. It is found that there is no transformation made for fields of pushed condition. field_transformer_for_having_pushdown transformer is added. New tests are added. Some comments are changed.
* | | | | Merge 10.3 into 10.4Marko Mäkelä2019-03-221-1/+1
|\ \ \ \ \ | |/ / / /
| * | | | Merge remote-tracking branch 'origin/10.2' into 10.3Alexander Barkov2019-03-221-1/+1
| |\ \ \ \ | | |/ / /
| | * | | Merge 10.1 into 10.2Marko Mäkelä2019-03-221-1/+1
| | |\ \ \ | | | |/ /
| | | * | Merge 10.0 into 10.1Marko Mäkelä2019-03-211-1/+1
| | | |\ \
| | | | * \ Merge 5.5 into 10.0Marko Mäkelä2019-03-211-1/+1
| | | | |\ \ | | | | | |/