MySQL 8.0.32
Source Code Documentation
group_index_skip_scan.cc File Reference
#include "sql/range_optimizer/group_index_skip_scan.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <new>
#include "my_dbug.h"
#include "my_sys.h"
#include "mysql/components/services/bits/psi_bits.h"
#include "prealloced_array.h"
#include "sql/handler.h"
#include "sql/item_sum.h"
#include "sql/psi_memory_key.h"
#include "sql/range_optimizer/index_range_scan.h"
#include "sql/range_optimizer/internal.h"
#include "sql/range_optimizer/tree.h"
#include "sql/sql_class.h"
#include "sql/sql_list.h"
#include "sql/sql_optimizer.h"
#include "sql/system_variables.h"
#include "sql/table.h"
#include "sql/thr_malloc.h"

Functions

static ha_rkey_function get_search_mode (QUICK_RANGE *cur_range, bool is_asc, bool is_min)
 Function returns search mode that needs to be used to read the next record. More...
 

Function Documentation

◆ get_search_mode()

static ha_rkey_function get_search_mode ( QUICK_RANGE cur_range,
bool  is_asc,
bool  is_min 
)
static

Function returns search mode that needs to be used to read the next record.

It takes the type of the range, the key part's order (ascending or descending) and if the range is on MIN function or a MAX function to get the right search mode. For "MIN" function:

  • ASC keypart We need to
    1. Read the first key that matches the range a) if a minimum value is not specified in the condition b) if it is a equality or is NULL condition
    2. Read the first key after a range value if range is like "a > 10"
    3. Read the key that matches the condition or any key after the range value for any other condition
  • DESC keypart We need to
    1. Read the last value for the key prefix if there is no minimum range specified.
    2. Read the first key that matches the range if it is a equality condition.
    3. Read the first key before a range value if range is like "a > 10"
    4. Read the key that matches the prefix or any key before for any other condition For MAX function:
  • ASC keypart We need to
    1. Read the last value for the key prefix if there is no maximum range specified
    2. Read the first key that matches the range if it is a equality condition
  1. Read the first key before a range value if range is like "a < 10"
  2. Read the key that matches the condition or any key before the range value for any other condition
  • DESC keypart We need to
  1. Read the first key that matches the range a) if a minimum value is not specified in the condition b) if it is a equality
  2. Read the first key after a range value if range is like "a < 10"
  3. Read the key that matches the prefix or any key after for any other condition
Parameters
cur_rangepointer to QUICK_RANGE.
is_ascTRUE if key part is ascending, FALSE otherwise.
is_minTRUE if the range is on MIN function. FALSE for MAX function.
Returns
search mode