~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/table_read_plan.h

  • Committer: Monty Taylor
  • Date: 2010-03-11 18:27:20 UTC
  • mfrom: (1333 staging)
  • mto: This revision was merged to the branch mainline in revision 1348.
  • Revision ID: mordred@inaugust.com-20100311182720-hd1h87y6cb1b1mp0
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
100
100
 
101
101
public:
102
102
 
103
 
  SEL_ARG *key; /* set of intervals to be used in "range" method retrieval */
104
 
  uint32_t     key_idx; /* key number in Parameter::key */
105
 
  uint32_t     mrr_flags;
106
 
  uint32_t     mrr_buf_size;
107
 
 
108
103
  RangeReadPlan(SEL_ARG *key_arg, uint32_t idx_arg, uint32_t mrr_flags_arg)
109
104
    :
110
105
      key(key_arg),
111
106
      key_idx(idx_arg),
112
 
      mrr_flags(mrr_flags_arg)
 
107
      mrr_flags(mrr_flags_arg),
 
108
      mrr_buf_size(0)
113
109
  {}
 
110
 
114
111
  virtual ~RangeReadPlan() {}                     /* Remove gcc warning */
115
112
 
116
113
  QuickSelectInterface *make_quick(Parameter *param, bool, memory::Root *parent_alloc);
117
114
 
 
115
  void setMRRBufferSize(uint32_t in_mrr_buf_size)
 
116
  {
 
117
    mrr_buf_size= in_mrr_buf_size;
 
118
  }
 
119
 
 
120
  uint32_t getKeyIndex() const
 
121
  {
 
122
    return key_idx;
 
123
  }
 
124
 
 
125
  uint32_t getMRRBufferSize() const
 
126
  {
 
127
    return mrr_buf_size;
 
128
  }
 
129
 
 
130
private:
 
131
 
 
132
  /** set of intervals to be used in "range" method retrieval */
 
133
  SEL_ARG *key;
 
134
  /** key number in Parameter::key */
 
135
  uint32_t     key_idx;
 
136
  uint32_t     mrr_flags;
 
137
  uint32_t     mrr_buf_size;
 
138
 
118
139
};
119
140
 
120
141
 
122
143
class RorIntersectReadPlan : public TableReadPlan
123
144
{
124
145
public:
125
 
  RorIntersectReadPlan() {}                      /* Remove gcc warning */
 
146
 
 
147
  RorIntersectReadPlan() 
 
148
    :
 
149
      ror_range_scans(),
 
150
      cpk_scan(NULL),
 
151
      is_covering(false),
 
152
      index_scan_costs(0.0)
 
153
  {}
 
154
 
126
155
  virtual ~RorIntersectReadPlan() {}             /* Remove gcc warning */
 
156
 
127
157
  QuickSelectInterface *make_quick(Parameter *param,
128
158
                                   bool retrieve_full_rows,
129
159
                                   memory::Root *parent_alloc);
130
160
 
131
 
  /* Array of pointers to ROR range scans used in this intersection */
132
 
  struct st_ror_scan_info **first_scan;
133
 
  struct st_ror_scan_info **last_scan; /* End of the above array */
 
161
  void setRowRetrievalNecessary(bool in_is_covering)
 
162
  {
 
163
    is_covering= in_is_covering;
 
164
  }
 
165
 
 
166
  void setCostOfIndexScans(double in_index_scan_costs)
 
167
  {
 
168
    index_scan_costs= in_index_scan_costs;
 
169
  }
 
170
 
 
171
  /**
 
172
   * @return true if row retrival phase is necessary.
 
173
   */
 
174
  bool isRowRetrievalNecessary() const
 
175
  {
 
176
    return ! is_covering;
 
177
  }
 
178
 
 
179
  /**
 
180
   * @return the sum of the cost of each index scan
 
181
   */
 
182
  double getCostOfIndexScans() const
 
183
  {
 
184
    return index_scan_costs;
 
185
  }
 
186
 
 
187
  /** Vector of pointers to ROR range scans used in this intersection */
 
188
  std::vector<struct st_ror_scan_info *> ror_range_scans;
134
189
  struct st_ror_scan_info *cpk_scan;  /* Clustered PK scan, if there is one */
135
 
  bool is_covering; /* true if no row retrieval phase is necessary */
136
 
  double index_scan_costs; /* SUM(cost(index_scan)) */
 
190
 
 
191
private:
 
192
 
 
193
  /** true if no row retrieval phase is necessary */
 
194
  bool is_covering; 
 
195
  /* SUM(cost(index_scan)) */
 
196
  double index_scan_costs; 
 
197
 
137
198
};
138
199
 
139
200
 
151
212
  QuickSelectInterface *make_quick(Parameter *param,
152
213
                                   bool retrieve_full_rows,
153
214
                                   memory::Root *parent_alloc);
154
 
  TableReadPlan **first_ror; /* array of ptrs to plans for merged scans */
155
 
  TableReadPlan **last_ror;  /* end of the above array */
 
215
  /** vector of plans for merged scans */
 
216
  std::vector<TableReadPlan *> merged_scans;
156
217
};
157
218
 
158
219
 
181
242
 
182
243
class GroupMinMaxReadPlan : public TableReadPlan
183
244
{
184
 
private:
185
 
  bool have_min;
186
 
  bool have_max;
187
 
  KEY_PART_INFO *min_max_arg_part;
188
 
  uint32_t group_prefix_len;
189
 
  uint32_t used_key_parts;
190
 
  uint32_t group_key_parts;
191
 
  KEY *index_info;
192
 
  uint32_t index;
193
 
  uint32_t key_infix_len;
194
 
  unsigned char key_infix[MAX_KEY_LENGTH];
195
 
  SEL_TREE *range_tree; /* Represents all range predicates in the query. */
196
 
  SEL_ARG *index_tree; /* The SEL_ARG sub-tree corresponding to index_info. */
197
 
  uint32_t param_idx; /* Index of used key in param->key. */
198
 
  /* Number of records selected by the ranges in index_tree. */
199
 
public:
200
 
  ha_rows quick_prefix_records;
201
 
 
202
 
public:
 
245
 
 
246
public:
 
247
 
203
248
  GroupMinMaxReadPlan(bool have_min_arg, 
204
249
                      bool have_max_arg,
205
250
                      KEY_PART_INFO *min_max_arg_part_arg,
215
260
                      uint32_t param_idx_arg, 
216
261
                      ha_rows quick_prefix_records_arg)
217
262
    :
 
263
      quick_prefix_records(quick_prefix_records_arg),
218
264
      have_min(have_min_arg),
219
265
      have_max(have_max_arg),
220
266
      min_max_arg_part(min_max_arg_part_arg),
226
272
      key_infix_len(key_infix_len_arg),
227
273
      range_tree(tree_arg),
228
274
      index_tree(index_tree_arg),
229
 
      param_idx(param_idx_arg),
230
 
      quick_prefix_records(quick_prefix_records_arg)
 
275
      param_idx(param_idx_arg)
231
276
    {
232
277
      if (key_infix_len)
233
278
        memcpy(this->key_infix, key_infix_arg, key_infix_len);
237
282
  QuickSelectInterface *make_quick(Parameter *param,
238
283
                                   bool retrieve_full_rows,
239
284
                                   memory::Root *parent_alloc);
 
285
 
 
286
  /* Number of records selected by the ranges in index_tree. */
 
287
  ha_rows quick_prefix_records;
 
288
 
 
289
private:
 
290
 
 
291
  bool have_min;
 
292
  bool have_max;
 
293
  KEY_PART_INFO *min_max_arg_part;
 
294
  uint32_t group_prefix_len;
 
295
  uint32_t used_key_parts;
 
296
  uint32_t group_key_parts;
 
297
  KEY *index_info;
 
298
  uint32_t index;
 
299
  uint32_t key_infix_len;
 
300
  unsigned char key_infix[MAX_KEY_LENGTH];
 
301
  SEL_TREE *range_tree; /* Represents all range predicates in the query. */
 
302
  SEL_ARG *index_tree; /* The SEL_ARG sub-tree corresponding to index_info. */
 
303
  uint32_t param_idx; /* Index of used key in param->key. */
240
304
};
241
305
 
242
306