mirror of
https://github.com/MariaDB/server.git
synced 2026-05-02 21:25:36 +02:00
MDEV-32958 Unusable key notes do not get reported for some operations
Enable unusable key notes for non-equality predicates:
<, <=, =>, >, BETWEEN, IN, LIKE
Note, in some scenarios it displays duplicate notes, e.g.
for queries with ORDER BY:
SELECT * FROM t1
WHERE indexed_string_column >= 10
ORDER BY indexed_string_column
LIMIT 5;
This should be tolarable. Getting rid of the diplicate note
completely would need a much more complex patch, which is
not desiable in 10.6.
Details:
- Changing RANGE_OPT_PARAM::note_unusable_keys from bool
to a new data type Item_func::Bitmap, so the caller can
choose with a better granuality which predicates
should raise unusable key notes inside the range optimizer:
a. all predicates (=, <=>, <, <=, =>, >, BETWEEN, IN, LIKE)
b. all predicates except equality (=, <=>)
c. none of the predicates
"b." is needed because in some scenarios equality predicates (=, <=>)
send unusable key notes at an earlier stage, before the range optimizer,
during update_ref_and_keys(). Calling the range optimizer with
"all predicates" would produce duplicate notes for = and <=> in such cases.
- Fixing get_quick_record_count() to call the range optimizer
with "all predicates except equality" instead of "none of the predicates".
Before this change the range optimizer suppressed all notes for
non-equality predicates: <, <=, =>, >, BETWEEN, IN, LIKE.
This actually fixes the reported problem.
- Fixing JOIN::make_range_rowid_filters() to call the range optimizer
with "all predicates except equality" instead of "all predicates".
Before this change the range optimizer produced duplicate notes
for = and <=> during a rowid_filter optimization.
- Cleanup:
Adding the op_collation argument to Field::raise_note_cannot_use_key_part()
and displaying the operation collation rather than the argument collation
in the unusable key note. This is important for operations with more than
two arguments: BETWEEN and IN, e.g.:
SELECT * FROM t1
WHERE column_utf8mb3_general_ci
BETWEEN 'a' AND 'b' COLLATE utf8mb3_unicode_ci;
SELECT * FROM t1
WHERE column_utf8mb3_general_ci
IN ('a', 'b' COLLATE utf8mb3_unicode_ci);
The note for 'a' now prints utf8mb3_unicode_ci as the collation.
which is the collation of the entire operation:
Cannot use key key1 part[0] for lookup:
"`column_utf8mb3_general_ci`" of collation `utf8mb3_general_ci` >=
"'a'" of collation `utf8mb3_unicode_ci`
Before this change it printed the collation of 'a',
so the note was confusing:
Cannot use key key1 part[0] for lookup:
"`column_utf8mb3_general_ci`" of collation `utf8mb3_general_ci` >=
"'a'" of collation `utf8mb3_general_ci`"
This commit is contained in:
parent
bc5e904043
commit
4ced4898fd
20 changed files with 412 additions and 25 deletions
|
|
@ -79,6 +79,38 @@ public:
|
|||
CASE_SEARCHED_FUNC, // Used by ColumnStore/Spider
|
||||
CASE_SIMPLE_FUNC, // Used by ColumnStore/spider,
|
||||
};
|
||||
|
||||
/*
|
||||
A function bitmap. Useful when some operation needs to be applied only
|
||||
to certain functions. For now we only need to distinguish some
|
||||
comparison predicates.
|
||||
*/
|
||||
enum Bitmap : ulonglong
|
||||
{
|
||||
BITMAP_NONE= 0,
|
||||
BITMAP_EQ= 1ULL << EQ_FUNC,
|
||||
BITMAP_EQUAL= 1ULL << EQUAL_FUNC,
|
||||
BITMAP_NE= 1ULL << NE_FUNC,
|
||||
BITMAP_LT= 1ULL << LT_FUNC,
|
||||
BITMAP_LE= 1ULL << LE_FUNC,
|
||||
BITMAP_GE= 1ULL << GE_FUNC,
|
||||
BITMAP_GT= 1ULL << GT_FUNC,
|
||||
BITMAP_LIKE= 1ULL << LIKE_FUNC,
|
||||
BITMAP_BETWEEN= 1ULL << BETWEEN,
|
||||
BITMAP_IN= 1ULL << IN_FUNC,
|
||||
BITMAP_MULT_EQUAL= 1ULL << MULT_EQUAL_FUNC,
|
||||
BITMAP_OTHER= 1ULL << 63,
|
||||
BITMAP_ALL= 0xFFFFFFFFFFFFFFFFULL,
|
||||
BITMAP_ANY_EQUALITY= BITMAP_EQ | BITMAP_EQUAL | BITMAP_MULT_EQUAL,
|
||||
BITMAP_EXCEPT_ANY_EQUALITY= BITMAP_ALL & ~BITMAP_ANY_EQUALITY,
|
||||
};
|
||||
|
||||
ulonglong bitmap_bit() const
|
||||
{
|
||||
Functype type= functype();
|
||||
return 1ULL << (type > 63 ? 63 : type);
|
||||
}
|
||||
|
||||
static scalar_comparison_op functype_to_scalar_comparison_op(Functype type)
|
||||
{
|
||||
switch (type) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue