MySQL  8.0.27
Source Code Documentation
sql_join_buffer.h
Go to the documentation of this file.
1 #ifndef SQL_JOIN_CACHE_INCLUDED
2 #define SQL_JOIN_CACHE_INCLUDED
3 
4 /* Copyright (c) 2000, 2021, Oracle and/or its affiliates.
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License, version 2.0,
8  as published by the Free Software Foundation.
9 
10  This program is also distributed with certain software (including
11  but not limited to OpenSSL) that is licensed under separate terms,
12  as designated in a particular file or component or in included license
13  documentation. The authors of MySQL hereby grant you an additional
14  permission to link the program and your derivative works with the
15  separately licensed software that they have included with MySQL.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License, version 2.0, for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25 
26 class QEP_TAB;
27 struct MEM_ROOT;
28 struct MY_BITMAP;
29 struct TABLE;
30 
31 /**
32  Filter the base columns of virtual generated columns if using a covering index
33  scan.
34 
35  Adjust table->read_set so that it only contains the columns that are needed in
36  the join operation and afterwards.
37 
38  For a virtual generated column, all base columns are added to the read_set
39  of the table. The storage engine will then copy all base column values so
40  that the value of the GC can be calculated inside the executor.
41  But when a virtual GC is fetched using a covering index, the actual GC
42  value is fetched by the storage engine and the base column values are not
43  needed. Code that looks at the read sets (join buffering, hash join, filesort)
44  must not try to copy them.
45  So, we eliminate from read_set those columns that are available from the
46  covering index.
47 
48  Note that some iterators (DynamicRangeIterator and AlternativeIterator)
49  may need to switch back to table scans. If so, they will adjust the table's
50  read set before reading; see add_virtual_gcol_base_cols().
51 */
53 
54 /**
55  Create a read set that undoes the work of filter_virtual_gcol_base_cols();
56  ie., for every virtual generated column that is part of the given table's read
57  set, we also include the base tables. This is needed if we revert from
58  a covering index back to a table scan (which doesn't store the virtual
59  generated columns themselves, unlike the covering index). This happens in
60  DynamicRangeIterator and AlternativeIterator.
61 
62  The new read set gets a new buffer, allocated on the given MEM_ROOT.
63  table->read_set is not changed.
64  */
66  MY_BITMAP *completed_read_set);
67 
68 class JOIN_CACHE {
69  public:
70  /** Bits describing cache's type @sa setup_join_buffering() */
71  enum enum_join_cache_type { ALG_NONE = 0, ALG_BNL = 1, ALG_BKA = 2 };
72 };
73 
74 #endif /* SQL_JOIN_CACHE_INCLUDED */
Definition: sql_join_buffer.h:68
enum_join_cache_type
Bits describing cache's type.
Definition: sql_join_buffer.h:71
@ ALG_BKA
Definition: sql_join_buffer.h:71
@ ALG_NONE
Definition: sql_join_buffer.h:71
@ ALG_BNL
Definition: sql_join_buffer.h:71
Definition: sql_executor.h:256
static MEM_ROOT mem_root
Definition: client_plugin.cc:109
void filter_virtual_gcol_base_cols(const QEP_TAB *qep_tab)
Filter the base columns of virtual generated columns if using a covering index scan.
Definition: sql_join_buffer.cc:106
void add_virtual_gcol_base_cols(TABLE *table, MEM_ROOT *mem_root, MY_BITMAP *completed_read_set)
Create a read set that undoes the work of filter_virtual_gcol_base_cols(); ie., for every virtual gen...
Definition: sql_join_buffer.cc:148
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:78
Definition: my_bitmap.h:41
Definition: table.h:1394
class QEP_TAB * qep_tab
Definition: table.h:1737