1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008-2009 Sun Microsystems, Inc.
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#include <drizzled/memory/sql_alloc.h>
23
#include <drizzled/util/functors.h>
30
Table rows retrieval plan. Range optimizer creates QuickSelectInterface-derived
31
objects from table read plans.
33
class TableReadPlan : public memory::SqlAlloc
37
Plan read cost, with or without cost of full row retrieval, depending
38
on plan creation parameters.
41
ha_rows records; /* estimate of #rows to be examined */
44
If true, the scan returns rows in rowid order. This is used only for
45
scans that can be both ROR and non-ROR.
50
Create quick select for this plan.
53
param Parameter from test_quick_select
54
retrieve_full_rows If true, created quick select will do full record
56
parent_alloc Memory pool to use, if any.
59
retrieve_full_rows is ignored by some implementations.
65
virtual QuickSelectInterface *make_quick(Parameter *param,
66
bool retrieve_full_rows,
67
memory::Root *parent_alloc= NULL) = 0;
69
virtual ~TableReadPlan() {} /* Remove gcc warning */
74
Plan for a QuickRangeSelect scan.
75
RangeReadPlan::make_quick ignores retrieve_full_rows parameter because
76
QuickRangeSelect doesn't distinguish between 'index only' scans and full
77
record retrieval scans.
79
class RangeReadPlan : public TableReadPlan
82
SEL_ARG *key; /* set of intervals to be used in "range" method retrieval */
83
uint32_t key_idx; /* key number in Parameter::key */
85
uint32_t mrr_buf_size;
87
RangeReadPlan(SEL_ARG *key_arg, uint32_t idx_arg, uint32_t mrr_flags_arg)
91
mrr_flags(mrr_flags_arg)
94
QuickSelectInterface *make_quick(Parameter *param, bool, memory::Root *parent_alloc);
98
/* Plan for QuickRorIntersectSelect scan. */
99
class RorIntersectReadPlan : public TableReadPlan
102
QuickSelectInterface *make_quick(Parameter *param,
103
bool retrieve_full_rows,
104
memory::Root *parent_alloc);
106
/* Array of pointers to ROR range scans used in this intersection */
107
RorScanInfo **first_scan;
108
RorScanInfo **last_scan; /* End of the above array */
109
RorScanInfo *cpk_scan; /* Clustered PK scan, if there is one */
111
bool is_covering; /* true if no row retrieval phase is necessary */
112
double index_scan_costs; /* SUM(cost(index_scan)) */
118
Plan for QuickRorUnionSelect scan.
119
QuickRorUnionSelect always retrieves full rows, so retrieve_full_rows
120
is ignored by make_quick.
123
class RorUnionReadPlan : public TableReadPlan
126
QuickSelectInterface *make_quick(Parameter *param,
127
bool retrieve_full_rows,
128
memory::Root *parent_alloc);
129
TableReadPlan **first_ror; /* array of ptrs to plans for merged scans */
130
TableReadPlan **last_ror; /* end of the above array */
135
Plan for QuickIndexMergeSelect scan.
136
QuickRorIntersectSelect always retrieves full rows, so retrieve_full_rows
137
is ignored by make_quick.
140
class IndexMergeReadPlan : public TableReadPlan
143
QuickSelectInterface *make_quick(Parameter *param,
144
bool retrieve_full_rows,
145
memory::Root *parent_alloc);
146
RangeReadPlan **range_scans; /* array of ptrs to plans of merged scans */
147
RangeReadPlan **range_scans_end; /* end of the array */
152
Plan for a QuickGroupMinMaxSelect scan.
155
class GroupMinMaxReadPlan : public TableReadPlan
160
KeyPartInfo *min_max_arg_part;
161
uint32_t group_prefix_len;
162
uint32_t used_key_parts;
163
uint32_t group_key_parts;
166
uint32_t key_infix_len;
167
unsigned char key_infix[MAX_KEY_LENGTH];
168
SEL_TREE *range_tree; /* Represents all range predicates in the query. */
169
SEL_ARG *index_tree; /* The SEL_ARG sub-tree corresponding to index_info. */
170
uint32_t param_idx; /* Index of used key in param->key. */
171
/* Number of records selected by the ranges in index_tree. */
173
ha_rows quick_prefix_records;
176
GroupMinMaxReadPlan(bool have_min_arg,
178
KeyPartInfo *min_max_arg_part_arg,
179
uint32_t group_prefix_len_arg,
180
uint32_t used_key_parts_arg,
181
uint32_t group_key_parts_arg,
182
KeyInfo *index_info_arg,
184
uint32_t key_infix_len_arg,
185
unsigned char *key_infix_arg,
187
SEL_ARG *index_tree_arg,
188
uint32_t param_idx_arg,
189
ha_rows quick_prefix_records_arg)
191
have_min(have_min_arg),
192
have_max(have_max_arg),
193
min_max_arg_part(min_max_arg_part_arg),
194
group_prefix_len(group_prefix_len_arg),
195
used_key_parts(used_key_parts_arg),
196
group_key_parts(group_key_parts_arg),
197
index_info(index_info_arg),
199
key_infix_len(key_infix_len_arg),
200
range_tree(tree_arg),
201
index_tree(index_tree_arg),
202
param_idx(param_idx_arg),
203
quick_prefix_records(quick_prefix_records_arg)
206
memcpy(this->key_infix, key_infix_arg, key_infix_len);
209
QuickSelectInterface *make_quick(Parameter *param,
210
bool retrieve_full_rows,
211
memory::Root *parent_alloc);
215
} /* namespace optimizer */
217
} /* namespace drizzled */