25
25
#include "drizzled/field/varstring.h"
26
26
#include "drizzled/item/null.h"
27
27
#include <drizzled/enum_nested_loop_state.h>
28
#include <drizzled/optimizer/position.h>
29
#include <drizzled/optimizer/sargable_param.h>
28
30
#include "drizzled/join_cache.h"
29
31
#include "drizzled/join_table.h"
32
36
class select_result;
81
85
enum_nested_loop_state end_send_group(JOIN *join, JoinTable *join_tab, bool end_of_records);
82
86
enum_nested_loop_state end_write_group(JOIN *join, JoinTable *join_tab, bool end_of_records);
85
* Information about a position of table within a join order. Used in join
99
use_insideout_scan(false)
103
* Determine whether the table this particular position is representing in
104
* the query plan is a const table or not. A constant table is defined as
105
* (taken from the MySQL optimizer internals document on MySQL forge):
107
* 1) A table with zero rows, or with only one row
108
* 2) A table expression that is restricted with a WHERE condition
110
* Based on the definition above, when records_read is set to 1.0 in the
111
* Position class, it infers that this position in the partial plan
112
* represents a const table.
114
* @return true if this position represents a const table; false otherwise
116
bool isConstTable() const
118
return (records_read < 2.0);
122
The "fanout": number of output rows that will be produced (after
123
pushed down selection condition is applied) per each row combination of
124
previous tables. The value is an in-precise estimate.
129
Cost accessing the table in course of the entire complete join execution,
130
i.e. cost of one access method use (e.g. 'range' or 'ref' scan ) times
131
number the access method will be invoked.
137
NULL - 'index' or 'range' or 'index_merge' or 'ALL' access is used.
138
Other - [eq_]ref[_or_null] access is used. Pointer to {t.keypart1 = expr}
142
/** If ref-based access is used: bitmap of tables this table depends on */
143
table_map ref_depend_map;
145
bool use_insideout_scan;
148
88
typedef struct st_rollup
150
90
enum State { STATE_NONE, STATE_INITED, STATE_READY };
157
97
#include "drizzled/join.h"
159
typedef struct st_select_check {
160
uint32_t const_ref,reg_ref;
164
This structure is used to collect info on potentially sargable
165
predicates in order to check whether they become sargable after
166
reading const tables.
167
We form a bitmap of indexes that can be used for sargable predicates.
168
Only such indexes are involved in range analysis.
170
typedef struct st_sargable_param
172
Field *field; /* field against which to check sargability */
173
Item **arg_value; /* values of potential keys for lookups */
174
uint32_t num_values; /* number of values in the above array */
178
* Structure used when finding key fields
180
typedef struct key_field_t
183
Item *val; /**< May be empty if diff constant */
185
uint32_t optimize; /**< KEY_OPTIMIZE_* */
188
If true, the condition this struct represents will not be satisfied
192
bool *cond_guard; /**< @see KeyUse::cond_guard */
195
99
/*****************************************************************************
196
100
Make som simple condition optimization:
197
101
If there is a test 'field = const' change all refs to 'field' to 'const'
266
170
bool change_group_ref(Session *session, Item_func *expr, order_st *group_list, bool *changed);
267
171
bool check_interleaving_with_nj(JoinTable *last, JoinTable *next);
269
int join_read_const_table(JoinTable *tab, Position *pos);
173
int join_read_const_table(JoinTable *tab, drizzled::optimizer::Position *pos);
270
174
int join_read_system(JoinTable *tab);
271
175
int join_read_const(JoinTable *tab);
272
176
int join_read_key(JoinTable *tab);
325
229
table_map normal_tables,
326
230
Select_Lex *select_lex,
327
SARGABLE_PARAM **sargables);
231
std::vector<drizzled::optimizer::SargableParam> &sargables);
328
232
ha_rows get_quick_record_count(Session *session, SQL_SELECT *select, Table *table, const key_map *keys,ha_rows limit);
329
233
void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array);
330
234
void add_group_and_distinct_keys(JOIN *join, JoinTable *join_tab);