An error occurred fetching the project authors.
  1. 04 May, 2023 1 commit
  2. 28 Apr, 2023 1 commit
    • Sergei Petrunia's avatar
      MDEV-31067: selectivity_from_histogram >1.0 for a DOUBLE_PREC_HB histogram · 85cc8318
      Sergei Petrunia authored
      Variant #2.
      
      When Histogram::point_selectivity() sees that the point value of interest
      falls into one bucket, it tries to guess whether the bucket has many
      different (unpopular) values or a few popular values. (The number of
      rows is fixed, as it's a Height-balanced histogram).
      The basis for this guess is the "width" of the value range the bucket
      covers. Buckets covering wider value ranges are assumed to contain
      values with proportionally lower frequencies.
      
      This is just a [brave] guesswork. For a very narrow bucket, it may
      produce an estimate that's larger than total #rows in the bucket
      or even in the whole table.
      
      Remove the guesswork and replace it with basic logic: return
      either the per-table average selectivity of col=const, or selectivity
      of one bucket, whichever is lower.
      85cc8318
  3. 26 Apr, 2023 1 commit
  4. 13 Dec, 2022 1 commit
    • Sergei Petrunia's avatar
      MDEV-30218: Incorrect optimization for rowid_filtering · 87eccd78
      Sergei Petrunia authored
      (Patch from Monty, slightly amended)
      
      Fix rowid filtering optimization in best_access_path():
      
      == Ref access + rowid filtering ==
      The cost computations compare #records and index-only scan cost
      (keyread_tmp) to find out the per-record advantage one will get if
      they skip reading full table record.
      
      The computations produce wrong result when:
      
      - the #records are "clipped down" with s->worst_seeks or
        thd->variables.max_seeks_for_key. keyread_tmp is not clipped
        this way so the numbers are not comparable.
      
      - access_factor is negative. This means index_only read is
        cheaper than non-index-only read.
      
      This patch makes the optimizer not to consider Rowid Filtering in
      such cases.
      The decision is logged in the Optimizer Trace using
      "rowid_filter_skipped" name.
      
      == Range access + rowid filtering ==
      when considering to use Rowid Filter with range access, do multiply
      keyread_tmp by record_count. That way, it is comparable with the
      range access's estimate, which is multiplied by record_count.
      87eccd78
  5. 26 Jul, 2022 2 commits
    • Monty's avatar
      Added EQ_REF chaining to the greedy_optimizer · 515b9ad0
      Monty authored
      MDEV-28073 Slow query performance in MariaDB when using many table
      
      The idea is to prefer and chain EQ_REF tables (tables that uses an
      unique key to find a row) when searching for the best table combination.
      This significantly reduces row combinations that has to be examined.
      This is optimization is enabled when setting optimizer_prune_level=2
      (which is now default).
      
      Implementation:
      - optimizer_prune_level has a new level, 2, which enables EQ_REF
        optimization in addition to the pruning done by level 1.
        Level 2 is now default.
      - Added JOIN::eq_ref_tables that contains bits of tables that could use
        potentially use EQ_REF access in the query.  This is calculated
        in sort_and_filter_keyuse()
      
      Under optimizer_prune_level=2:
      - When the greedy_optimizer notices that the preceding table was an
        EQ_REF table, it tries to add an EQ_REF table next. If an EQ_REF
        table exists, only this one will be considered at this level.
        We also collect all EQ_REF tables chained by the next levels and these
        are ignored on the starting level as we have already examined these.
        If no EQ_REF table exists, we continue as normal.
      
      This optimization speeds up the greedy_optimizer combination test with
      ~25%
      
      Other things:
      - I ported the changes in MySQL 5.7 to greedy_optimizer.test to MariaDB
        to be able to ensure we can handle all cases that MySQL can do.
      - I have run all tests with --mysqld=--optimizer_prune_level=1 to verify that
        there where no test changes.
      515b9ad0
    • Monty's avatar
      Improve pruning in greedy_search by sorting tables during search · b3c74bdc
      Monty authored
      MDEV-28073 Slow query performance in MariaDB when using many tables
      
      The faster we can find a good query plan, the more options we have for
      finding and pruning (ignoring) bad plans.
      
      This patch adds sorting of plans to best_extension_by_limited_search().
      The plans, from best_access_path() are sorted according to the numbers
      of found rows.  This allows us to faster find 'good tables' and we are
      thus able to eliminate 'bad plans' faster.
      
      One side effect of this patch is that if two tables have equal cost,
      the table that which was used earlier in the query is preferred.
      This allows users to improve plans by reordering eq_ref tables in the
      order they would like them to be uses.
      
      Result changes caused by the patch:
      - Traces are different as now we print the cost for using tables before
        we start considering them in the plan.
      - Table order are changed for some plans. In most cases this is because
        the plans are equal and tables are in this case sorted according to
        their usage in the original query.
      - A few plans was changed as the optimizer was able to find a better
        plan (that was pruned by the original code).
      
      Other things:
      
      - Added a new statistic variable: "optimizer_join_prefixes_check_calls",
        which counts number of calls to best_extension_by_limited_search().
        This can be used to check the prune efficiency in greedy_search().
      - Added variable "JOIN_TAB::embedded_dependent" to be able to handle
        XX IN (SELECT..) in the greedy_optimizer.  The idea is that we
        should prune a table if any of the tables in embedded_dependent is
        not yet read.
      - When using many tables in a query, there will be some additional
        memory usage as we need to pre-allocate table of
        table_count*table_count*sizeof(POSITION) objects (POSITION is 312
        bytes for now) to hold the pre-calculated best_access_path()
        information.  This memory usage is offset by the expected
        performance improvement when using many tables in a query.
      - Removed the code from an earlier patch to keep the table order in
        join->best_ref in the original order.  This is not needed anymore as we
        are now sorting the tables for each best_extension_by_limited_search()
        call.
      b3c74bdc
  6. 07 Jun, 2022 1 commit
    • Michael Widenius's avatar
      Improve table pruning in optimizer with up to date key_dependent map · 432a4ebe
      Michael Widenius authored
      Part of:
      MDEV-28073 Slow query performance in MariaDB when using many tables
      
      s->key_dependent has a list of tables that are compared with key fields
      in the current table.  However it does not take into account if a key
      field could be resolved by another table.
      This is because MariaDB expands 'join_tab->keyuse' to include all generated
      comparisons.
      For example:
      SELECT * from t1,t2,t3 where t1.key=t2.key and t2.key=t3.key
      In this case keyuse for t1 includes t2.key and t3.key and key_dependent
      contains 't2.map | t3.map'
      If we in best_extension_by_limited_search() consider t2,t1 then t1's
      key is fully defined, but we cannot do any prune of plans as
      s->key_dependent indicates that t3 is still needed.
      
      Fixed by calculating in best_access_patch the current key_dependent map
      of tables that is needed to satisfy all keys. This allows us to prune
      more bad plans earlier as soon as all keys can be used.
      
      We also set key_dependent to 0 if we found an EQ_REF key, as this an
      optimal key for the table and there is no reason to check more keys.
      432a4ebe
  7. 19 Jan, 2022 2 commits
  8. 31 Aug, 2021 1 commit
    • Marko Mäkelä's avatar
      MDEV-4750 follow-up: Reduce disabling innodb_stats_persistent · 9608773f
      Marko Mäkelä authored
      This essentially reverts commit 4e89ec66
      and only disables InnoDB persistent statistics for tests where it is
      desirable. By design, InnoDB persistent statistics will not be updated
      except by ANALYZE TABLE or by STATS_AUTO_RECALC.
      
      The internal transactions that update persistent InnoDB statistics
      in background tasks (with innodb_stats_auto_recalc=ON) may cause
      nondeterministic query plans or interfere with some tests that deal
      with other InnoDB internals, such as the purge of transaction history.
      9608773f
  9. 27 Mar, 2020 1 commit
    • Monty's avatar
      Updated optimizer costs in multi_range_read_info_const() and sql_select.cc · eb483c51
      Monty authored
      - multi_range_read_info_const now uses the new records_in_range interface
      - Added handler::avg_io_cost()
      - Don't calculate avg_io_cost() in get_sweep_read_cost if avg_io_cost is
        not 1.0.  In this case we trust the avg_io_cost() from the handler.
      - Changed test_quick_select to use TIME_FOR_COMPARE instead of
        TIME_FOR_COMPARE_IDX to align this with the rest of the code.
      - Fixed bug when using test_if_cheaper_ordering where we didn't use
        keyread if index was changed
      - Fixed a bug where we didn't use index only read when using order-by-index
      - Added keyread_time() to HEAP.
        The default keyread_time() was optimized for blocks and not suitable for
        HEAP. The effect was the HEAP prefered table scans over ranges for btree
        indexes.
      - Fixed get_sweep_read_cost() for HEAP tables
      - Ensure that range and ref have same cost for simple ranges
        Added a small cost (MULTI_RANGE_READ_SETUP_COST) to ranges to ensure
        we favior ref for range for simple queries.
      - Fixed that matching_candidates_in_table() uses same number of records
        as the rest of the optimizer
      - Added avg_io_cost() to JT_EQ_REF cost. This helps calculate the cost for
        HEAP and temporary tables better. A few tests changed because of this.
      - heap::read_time() and heap::keyread_time() adjusted to not add +1.
        This was to ensure that handler::keyread_time() doesn't give
        higher cost for heap tables than for normal tables. One effect of
        this is that heap and derived tables stored in heap will prefer
        key access as this is now regarded as cheap.
      - Changed cost for index read in sql_select.cc to match
        multi_range_read_info_const(). All index cost calculation is now
        done trough one function.
      - 'ref' will now use quick_cost for keys if it exists. This is done
        so that for '=' ranges, 'ref' is prefered over 'range'.
      - scan_time() now takes avg_io_costs() into account
      - get_delayed_table_estimates() uses block_size and avg_io_cost()
      - Removed default argument to test_if_order_by_key(); simplifies code
      eb483c51
  10. 13 Feb, 2020 1 commit
  11. 06 Sep, 2019 1 commit
  12. 18 Feb, 2019 1 commit
    • Sergei Petrunia's avatar
      MDEV-18608: Defaults for 10.4: histogram size should be set · 15a77a1a
      Sergei Petrunia authored
      Change the defaults:
      
      -histogram_size=0
      +histogram_size=254
      
      -histogram_type=SINGLE_PREC_HB
      +histogram_type=DOUBLE_PREC_HB
      
      Adjust the testcases:
      - Some have ignorable changes in EXPLAIN outputs and
        more counter increments due to EITS table reads.
      - Testcases that meaningfully depend on the old defaults
        are changed to use the old values.
      15a77a1a
  13. 10 Dec, 2018 1 commit
  14. 25 Jun, 2018 1 commit
  15. 29 Mar, 2018 1 commit
  16. 30 Dec, 2017 1 commit
  17. 02 Dec, 2017 1 commit
    • Monty's avatar
      Mark constant 'null_tables' with table->const_table=1 · c65911ac
      Monty authored
      This was done to make thing consistent. It gives the additional benefit
      that EXPLAIN EXTENDED now treat null_tables like constant's and replaces
      columns with NULL, in a similar way that it replaces columns with constants
      for constant tables.
      
      - Null tables are tables where all columns are always NULL. The most common
        NULL TABLE is a table used in a LEFT_JOIN that is never true.
      - All result changes comes from replacing columns with NULL for null_tables.
      - "Impossible where" is now also shows constants for const columns.
      - Removed duplicated s->type= JT_CONST
      - Reset found_const_table_map when JOIN is created (safety fix)
      c65911ac
  18. 28 Oct, 2017 1 commit
    • Galina Shalygina's avatar
      Mistakes corrected. · a4ded0a9
      Galina Shalygina authored
      TVC can be used in IN subquery and in PARTITION BY struct now.
      Special variable to control working of optimization added.
      a4ded0a9
  19. 10 Aug, 2017 1 commit
  20. 14 Mar, 2017 1 commit
  21. 13 Mar, 2017 1 commit
  22. 14 Dec, 2016 1 commit
    • Varun Gupta's avatar
      MDEV-11060 sql/protocol.cc:532: void Protocol::end_statement(): Assertion `0' failed · f41bd7e5
      Varun Gupta authored
      In file sql/opt_range.cc,when calculate_cond_selectivity_for_table() is called with optimizer_use_condition_selectivity=4 then
      	- thd->no_errors is set to 1
      	- the original value of thd->no_error is not restored to its original value
      	- this is causing the assertion to fail in the subsequent queries
      
      Fixed by restoring the original value of thd->no_errors
      f41bd7e5
  23. 12 Dec, 2016 2 commits
  24. 29 Nov, 2016 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-11364. · 748d993c
      Igor Babaev authored
      The function Item_func_isnull::update_used_tables() must
      handle the case when the predicate is over not nullable
      column in a special way.
      This is actually a bug of MariaDB 5.3/5.5, but it's probably
      hard to demonstrate that it can cause problems there.
      748d993c
  25. 27 Oct, 2016 2 commits
    • Igor Babaev's avatar
      Fixed bug mdev-9628. · d451d772
      Igor Babaev authored
      In the function create_key_parts_for_pseudo_indexes()
      the key part structures of pseudo-indexes created for
      BLOB fields were set incorrectly.
      Also the key parts for long fields must be 'truncated'
      up to the maximum length acceptable for key parts.
      d451d772
    • Igor Babaev's avatar
      Fixed bug mdev-11096. · 9d4a0dde
      Igor Babaev authored
      1. When min/max value is provided the null flag for it must be set to 0
      in the bitmap Culumn_statistics::column_stat_nulls.
      2. When the calculation of the selectivity of the range condition
      over a column requires min and max values for the column then we
      have to check that these values are provided.
      9d4a0dde
  26. 02 Sep, 2016 1 commit
    • Jan Lindström's avatar
      Merge InnoDB 5.7 from mysql-5.7.9. · 2e814d47
      Jan Lindström authored
      Contains also
      
      MDEV-10547: Test multi_update_innodb fails with InnoDB 5.7
      
      	The failure happened because 5.7 has changed the signature of
      	the bool handler::primary_key_is_clustered() const
      	virtual function ("const" was added). InnoDB was using the old
      	signature which caused the function not to be used.
      
      MDEV-10550: Parallel replication lock waits/deadlock handling does not work with InnoDB 5.7
      
      	Fixed mutexing problem on lock_trx_handle_wait. Note that
      	rpl_parallel and rpl_optimistic_parallel tests still
      	fail.
      
      MDEV-10156 : Group commit tests fail on 10.2 InnoDB (branch bb-10.2-jan)
        Reason: incorrect merge
      
      MDEV-10550: Parallel replication can't sync with master in InnoDB 5.7 (branch bb-10.2-jan)
        Reason: incorrect merge
      2e814d47
  27. 04 Sep, 2015 1 commit
  28. 25 Feb, 2015 1 commit
  29. 06 Feb, 2015 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-7316. · 587c7208
      Igor Babaev authored
      The function table_cond_selectivity() should take into account that condition selectivity
      for some fields can be set to 0.
      587c7208
  30. 11 Nov, 2014 1 commit
  31. 29 Oct, 2014 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-6843. · 100b10d8
      Igor Babaev authored
      The function  get_column_range_cardinality() returned a wrong result for any column
      containing only null values.
      100b10d8
  32. 28 Oct, 2014 1 commit
  33. 06 Oct, 2014 1 commit
    • Sergey Petrunya's avatar
      MDEV-6442: Assertion `join->best_read < double(...)' failed with... · fd4c9af3
      Sergey Petrunya authored
      MDEV-6442: Assertion `join->best_read < double(...)' failed with optimizer_use_condition_selectivity >=3
      
      - Fix the crash by making get_column_range_cardinality() 
        to handle the special case where Column_stats objects 
        is an all-zeros object (the question of what is the point
        of having Field::read_stats point to such object remains a 
        mystery)
      
      - Added a few comments. Learning the code still.
      
      fd4c9af3
  34. 10 Oct, 2014 1 commit
  35. 30 Sep, 2014 1 commit
  36. 09 Jun, 2014 1 commit