Commit graph

14 commits

Author SHA1 Message Date
Sergei Golubchik
180065ebb0 Item::print(): remove redundant parentheses
by introducing new Item::precedence() method and using it
to decide whether parentheses are required
2016-12-12 20:44:41 +01:00
Sergei Golubchik
23d03a1b1e parse negative numbers into one item
use Item->neg to convert generate negative Item_num's
instead of Item_func_neg(Item_num).

Based on the following commit:

  Author: Monty <monty@mariadb.org>
  Date:   Mon May 30 22:44:00 2016 +0300

    Make negative number their own token
    The negation (-) operator will call Item->neg() one underlying numeric constants
    and remove itself (like the NOT() function does today for other NOT functions.

    This simplifies things
    - -1 is not anymore an expression but a basic_const_item
      - improves optimizer
      - DEFAULT -1 doesn't need special handling anymore
      - When we add DEFAULT expressions, -1 will be treated exactly like 1
    - printing of items doesn't anymore put braces around all negative numbers

    Other things fixed:
    - Fixed that longlong converted to decimal's has a more appropriate size
    - Fixed that "-0.0" read into a decimal is interpreted as 0.0
2016-06-30 11:43:02 +02:00
Sergei Petrunia
9b9e36ed49 MDEV-8779: mysqld got signal 11 in sql/opt_range_mrr.cc:100(step_down_to)
The crash was caused by range optimizer using RANGE_OPT_PARAM::min_key
(and max_key) to store keys. Buffer size was a good upper bound for
range analysis and partition pruning, but not for EITS selectivity
calculations.

Fixed by making these buffers variable-size. The sizes are calculated
from [pseudo]indexes used for range analysis.
2015-09-21 17:08:27 +03:00
Sergei Golubchik
3d4dbe4d94 avoid uppercase table aliases tests - they're not portable 2014-06-11 19:08:06 +02:00
Sergey Petrunya
aeb62282a2 MDEV-5985: EITS: selectivity estimates look illogical for join and non-key equalities
Part#1. 

table_cond_selectivity() should discount selectivity of table' 
conditions only when ity counts that selectivity to begin with. 

For non-ref-based access methods (ALL/range/index_merge/etc),
we start with sel=1.0 and hence do not need to discount any
selectivities.
2014-06-10 12:25:16 +02:00
Sergey Petrunya
71df035551 MDEV-6308: Server crashes in table_multi_eq_cond_selectivity with ...
- In table_cond_selectivity(), reset keyuse variable between the loops.
2014-06-07 19:00:26 +02:00
Sergey Petrunya
504068b093 MDEV-6209: Assertion `join->best_read < double(1.79769313486231570815e+308L ...
- Use floating-point division in selectivity calculations.
2014-05-05 13:24:54 +03:00
Sergey Petrunya
54265c5f50 MDEV-5980: EITS: if condition is used for REF access, its selectivity is still in filtered%
- Testcase. The bug is fixed by commit for MDEV-6003
2014-04-25 19:12:06 +04:00
Sergey Petrunya
2acd81af73 MDEV-6003: EITS: ref access, keypart2=const vs keypart2=expr - inconsistent filtered% value
- Fix table_cond_selectivity() to work correctly for ref access 
  and "keypart2=const" case.
2014-04-25 19:04:54 +04:00
Sergey Petrunya
182f7d76ee Revert these two changes (wrong push) :
MDEV-5980: EITS: if condition is used for REF access, its selectivity is still in filtered%
MDEV-5985: EITS: selectivity estimates look illogical for join and non-key equalities
MDEV-6003: EITS: ref access, keypart2=const vs keypart2=expr - inconsistent filtered% value
- Made a number of fixes in table_cond_selectivity() so that it returns
  correct selectivity estimates.
- Added comments in related code.
Better comments
2014-04-28 21:49:39 +04:00
Sergey Petrunya
deb26989e9 MDEV-5980: EITS: if condition is used for REF access, its selectivity is still in filtered%
MDEV-5985: EITS: selectivity estimates look illogical for join and non-key equalities
MDEV-6003: EITS: ref access, keypart2=const vs keypart2=expr - inconsistent filtered% value
- Made a number of fixes in table_cond_selectivity() so that it returns
  correct selectivity estimates.
- Added comments in related code.
2014-04-21 15:37:55 +04:00
Sergey Petrunya
26a3d567c9 MDEV-5992: EITS: Selectivity of non-indexed condition is counted twice in table's fanout
MDEV-5984: EITS: Incorrect filtered% value for single-table select with range access
- Fix calculate_cond_selectivity_for_table() to work correctly with range accesses 
  over multi-component keys:
  = First, take selectivity of all possible range scans into account. Remember which 
    fields were used bt the range scans.
  = Then, calculate selectivity produced by sargable predicates on fields. If a 
    field was used in a possible range access, assume its selectivity is already
    taken into account.
- Fix table_cond_selectivity(): when quick select is used, selectivity of
  COND(table) is taken into account in matching_candidates_in_table(). In
  table_cond_selectivity() we should not apply it for the second time.
2014-04-01 09:59:51 -07:00
Sergey Petrunya
92e49bb066 MDEV-4360: ANALYZE shows "Table is already up to date" while updating stats
- Show a line with "Engine-independent statistics collected" when ANALYZE command
  caused EITS statistics to be recollected.
2014-03-28 00:32:53 +04:00
Sergey Petrunya
79a8a6130b Code cleanup:
- Move [some] engine-agnostic tests from t/selectivity.test to t/selectivity_no_engine.test
- Move Histogram::point_selectivity to sql_statistics.cc
2014-03-27 13:08:00 +04:00