[MDEV-15253] Default optimizer setting changes for MariaDB 10.4 Created: 2018-02-08  Updated: 2023-04-18  Resolved: 2018-12-09

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Fix Version/s: 10.4.1

Type: Task Priority: Critical
Reporter: Sergei Petrunia Assignee: Varun Gupta (Inactive)
Resolution: Fixed Votes: 1
Labels: defaults

Issue Links:
Blocks
is blocked by MDEV-16307 Incorrect results when using BNLH joi... Closed
Duplicate
duplicates MDEV-9999 Change the default value of optimizer... Closed
PartOf
includes MDEV-16374 filtered shows 0 for materilization s... Closed
includes MDEV-16695 Estimate for rows of derived tables i... Closed
includes MDEV-16921 Filtered shows 0 with derived tables/... Closed
includes MDEV-16995 ER_CANT_CREATE_GEOMETRY_OBJECT encoun... Closed
includes MDEV-17023 Crash during read_histogram_for_table... Closed
includes MDEV-17032 Estimates are higher for partitions o... Closed
includes MDEV-17039 Query plan changes when we use GROUP ... Closed
includes MDEV-17255 New optimizer defaults and ANALYZE TABLE Closed
includes MDEV-17297 stats.records=0 for a table of Archiv... Closed
includes MDEV-17752 Plan changes from hash_index_merge to... Closed
includes MDEV-17778 Alter table leads to a truncation war... Closed
includes MDEV-17784 Analyze table returns warnings due to... Stalled
Relates
relates to MDEV-13628 ORed condition in pushed index condit... Closed
relates to MDEV-13905 condition in pushed index condition i... Stalled
relates to MDEV-15321 different results when using value of... Closed
relates to MDEV-17734 AddressSanitizer: use-after-poison in... Closed
relates to MDEV-22537 optimizer_use_cond_selectivity > 1 ca... Closed
relates to MDEV-15306 Wrong/Unexpected result with the val... Closed
relates to MDEV-15368 Unnecessary condition used in Index C... Stalled
relates to MDEV-17903 New optimizer defaults: change optimi... Closed
relates to MDEV-18355 Switching the results for plans when ... Stalled
relates to MDEV-18551 New defaults for eq_range_index_dive_... Closed
relates to MDEV-18608 Defaults for 10.4: histogram size sho... Closed
Sprint: 10.4.0-1

 Description   

The current default settings are:

optimizer_use_condition_selectivity=1
use_stat_tables=NEVER

This means many optimizations are not enabled.

During discussion on the optimizer call, figured that we should use defaults like so:

optimizer_use_condition_selectivity=4
use_stat_tables=PREFERABLY

The task is:

  • change the defaults
  • This will cause some MTR test result differences
  • Go through the failing test and see:
    • some tests specifically require old settings. Set the variables for these tests.
    • some tests dont' update test results for these.

cc igor, cvicentiu, sanja, varun_raiko, shagalla



 Comments   
Comment by Sergei Petrunia [ 2018-02-08 ]

join_cache_level:

1 – flat (Block Nested Loop) BNL
2 – incremental BNL  -- *current default*
3 – flat Block Nested Loop Hash (BNLH)
4 – incremental BNLH  -- *new default*
5 – flat Batch Key Access (BKA)
6 – incremental BKA
7 – flat Batch Key Access Hash (BKAH)
8 – incremental BKAH

Comment by Sergei Petrunia [ 2018-02-08 ]

optimizer_use_condition_selectivity:

1 Use selectivity of predicates as in MariaDB 5.5. -- *current default *
2 Use selectivity of all range predicates supported by indexes.
3 Use selectivity of all range predicates estimated without histogram.
4 Use selectivity of all range predicates estimated with histogram. -- *new default *
5 Additionally use selectivity of certain non-range predicates calculated on record sample.

Note that histograms are not collected automatically, so the value of 4 will have the same effect as 3 for those who never collected histograms.

Comment by Sergei Petrunia [ 2018-02-08 ]

TODO: As a second step, should histogram_size default be changed from 0 to 255 ?

Comment by Daniel Black [ 2018-02-09 ]

If optimizer_use_condition_selectivity=4 then it would seem a little odd to keep histogram_size at 0. 255 seems like a good default to cover a broad range of values in a column with little cost if this isn't the case.

Comment by Varun Gupta (Inactive) [ 2018-02-16 ]

Milestone1: Increase the value for join_cache_level from 2 to 4

Comment by Daniel Black [ 2018-02-18 ]

varun de7a3b23ba66e0946adde0906f1972e80b0e700a had the wrong MDEV ref.

Comment by Varun Gupta (Inactive) [ 2018-05-30 ]

Well we are not going to change the value for join_cache_level. It will still remain to be 2. We are not having any improved performance gains here because there is no cost based approach for hash join and we unconditionally always prefer hash join.

Comment by Varun Gupta (Inactive) [ 2018-09-17 ]

The branch where all the changes is 10.4-selectivity4

Comment by Varun Gupta (Inactive) [ 2018-09-17 ]

One issue we came across while changing the defaults that ANALYZE on a table would become quite slow , because it will also calculate the EITS at the same time.

According to the docs:

With engine-independent statistics:
If @@use_stat_tables='never' and PERSISTENT FOR isn't used as part of the ALTER TABLE statement, then only storage engine statistics will be updated and not engine-independent statistics.
For other values of @@use_stat_tables, both storage engine statistics and engine-independent statistics will be updated.

Comment by Varun Gupta (Inactive) [ 2018-12-09 ]

Pushed to 10.4

Generated at Thu Feb 08 08:19:52 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.