maria:10.7-vicentiu-selectivity

Last commit made on 2022-07-02
Get this branch:
git clone -b 10.7-vicentiu-selectivity https://git.launchpad.net/maria

Branch merges

Branch information

Name:
10.7-vicentiu-selectivity
Repository:
lp:maria

Recent commits

baf8be9... by Vicențiu Ciorbaru

Implement cost_for_order_by function

The sort length is extracted similarly to how sortlength() function does
it. The function makes use of filesort_use_addons function to compute
the length of addon fields. Finally, by calling compute_sort_costs we
get the fastest_sort possible.

Other changes:
* Sort_param::using_addon_fields() assumes addon fields are already
  allocated. This makes the use of Sort_param unusable for
  compute_sort_costs *if* we don't want to allocate addon fields.

  As a preliminary fix, pass "with_addon_fields" as bool value to
  compute_sort_costs() and make the internal functions use that value
  instead of Sort_param::using_addon_fields() method.

  The ideal fix would be to define a "leaner" struct with only the
  necessary members, but this can be done as a separate commit.

* Remove unnecessary fields from Sort_costs::costs array.
  As we do not yet differentiate between merge sort with fixed length vs
  dynamic length fields, eliminate that differentiation from enum sort_type.
  It can be added at a later date when we indeed have a cost
  differentiation.

* Fixup comments

bb30310... by Vicențiu Ciorbaru

Refactor Sort_param::init_for_filesort

No logic changes.
Extract some of init_for_filesort logic into a separate function:
* Sort_param::setup_lengths_and_limit can be used to fill in the various
  xxx_length members of Sort_param, without having to allocate any of the other
  buffers.

fe9ec65... by Vicențiu Ciorbaru

cleanup: Typo fix appliccable -> applicable

fbf95ca... by Vicențiu Ciorbaru

Introduce cost computation for filesort operations

38d0291... by Vicențiu Ciorbaru

cleanup: Don't pass THD to get_merge_many_buff_cost_fast

We can pass the cost directly.

c604f8f... by Vicențiu Ciorbaru

cleanup: Make tempfile creation uniform with DISK_CHUNK_SIZE

Replace READ_RECORD_SIZE and DISK_BUFFER_SIZE (renamed to
DISK_CHUNK_SIZE) to be used across all open_cached_file calls.

d18b3cd... by Vicențiu Ciorbaru

cleanup: Rename Sort_param::max_rows to limit_rows

This makes the code easier to read as the intent of the parameter is
clearer.

4d43272... by Monty <email address hidden>

Fixed cost calculations for materialized tables

One effect of this change in the test suite is that tests with very few
rows changed to use sub queries instead of materialization. This is
correct and expected as for these the materialization overhead is too high.

A lot of tests where fixed to still use materialization by adding a
few rows to the tables (most tests has only 2-3 rows and are thus easily
affected when cost computations are changed).

Other things:
- Added more variables to TMPTABLE_COSTS for better cost calculation
- Added cost of copying rows to TMPTABLE_COSTS lookup and write
- Added THD::optimizer_cache_hit_ratio for easier cost calculations
- Added DISK_FAST_READ_SIZE to be used when calculating costs when
  reading big blocks from a disk

47a852b... by Monty <email address hidden>

Move join->emb_smj_nest setting to choose_plan()

This cleans up the interface for choose_plan() as it is not depending
on setting join->emb_sj_nest.

choose_plan() now sets up join->emb_sj_nest and join->allowed_tables before
calling optimize_straight_join() and best_extension_by_limited_search().

Other things:
- Removed "& ~join->const_table_map" as the constant tables should never
  be in sj_innert_tables.
- Converted some 'if' to DBUG_ASSERT() as these should always be true.
- Calculate 'allowed_tables' in choose_plan() as this never changes in
  the childs.
- Added assert to check that next_emb->nested_join->n_tables doesn't
  get to a wrong value.

b71455b... by Monty <email address hidden>

Simple optimization: Remove JOIN::set_group_rpa as it is not needed