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
20
#ifndef DRIZZLED_OPTIMIZER_RANGE_PARAM_H
21
#define DRIZZLED_OPTIMIZER_RANGE_PARAM_H
23
#include <boost/dynamic_bitset.hpp>
25
#include "drizzled/field.h"
30
typedef class Item COND;
31
typedef struct st_key_part KEY_PART;
46
covered_fields_size(0),
47
used_fields_covered(0),
50
first_uncovered_field(0),
54
boost::dynamic_bitset<> bitsToBitset() const;
56
void subtractBitset(const boost::dynamic_bitset<>& in_bitset);
58
uint32_t findFirstNotSet() const;
60
size_t getBitCount() const;
62
uint32_t idx; /* # of used key in param->keys */
63
uint32_t keynr; /* # of used key in table */
64
ha_rows records; /* estimate of # records this scan will return */
66
/* Set of intervals over key fields that will be used for row retrieval. */
67
optimizer::SEL_ARG *sel_arg;
69
/* Fields used in the query and covered by this ROR scan. */
70
uint64_t covered_fields;
71
size_t covered_fields_size;
72
uint32_t used_fields_covered; /* # of set bits in covered_fields */
73
int key_rec_length; /* length of key record (including rowid) */
76
Cost of reading all index records with values in sel_arg intervals set
77
(assuming there is no need to access full table records)
79
double index_read_cost;
80
uint32_t first_uncovered_field; /* first unused bit in covered_fields */
81
uint32_t key_components; /* # of parts in the key */
101
using_real_indexes(false),
102
remove_jump_scans(false),
104
force_default_mrr(false)
107
Session *session; /* Current thread handle */
108
Table *table; /* Table being analyzed */
109
COND *cond; /* Used inside get_mm_tree(). */
110
table_map prev_tables;
111
table_map read_tables;
112
table_map current_table; /* Bit of the table being analyzed */
114
/* Array of parts of all keys for which range analysis is performed */
116
KEY_PART *key_parts_end;
117
memory::Root *mem_root; /* Memory that will be freed when range analysis completes */
118
memory::Root *old_root; /* Memory that will last until the query end */
120
Number of indexes used in range analysis (In SEL_TREE::keys only first
121
#keys elements are not empty)
126
If true, the index descriptions describe real indexes (and it is ok to
127
call field->optimize_range(real_keynr[...], ...).
128
Otherwise index description describes fake indexes.
130
bool using_real_indexes;
132
bool remove_jump_scans;
135
used_key_no -> table_key_no translation table. Only makes sense if
136
using_real_indexes==true
138
uint32_t real_keynr[MAX_KEY];
139
/* Number of SEL_ARG objects allocated by optimizer::SEL_ARG::clone_tree operations */
140
uint32_t alloced_sel_args;
141
bool force_default_mrr;
144
class Parameter : public RangeParameter
155
tmp_covered_fields(),
157
imerge_cost_buff(NULL),
158
imerge_cost_buff_size(0),
163
KEY_PART *key[MAX_KEY]; /* First key parts of keys used in the query */
164
uint32_t max_key_part;
165
/* Number of ranges in the last checked tree->key */
166
uint32_t range_count;
167
unsigned char min_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH];
168
unsigned char max_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH];
169
bool quick; // Don't calulate possible keys
171
boost::dynamic_bitset<> needed_fields; /* bitmask of fields needed by the query */
172
boost::dynamic_bitset<> tmp_covered_fields;
174
key_map *needed_reg; /* ptr to SqlSelect::needed_reg */
176
uint32_t *imerge_cost_buff; /* buffer for index_merge cost estimates */
177
uint32_t imerge_cost_buff_size; /* size of the buffer */
179
/* true if last checked tree->key can be used for ROR-scan */
181
/* Number of ranges in the last checked tree->key */
185
} /* namespace optimizer */
187
} /* namespace drizzled */
189
#endif /* DRIZZLED_OPTIMIZER_RANGE_PARAM_H */