1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2009 Sun Microsystems
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_POSITION_H
21
#define DRIZZLED_OPTIMIZER_POSITION_H
23
#include <drizzled/join_table.h>
31
* Information about a position of table within a join order. Used in join
47
Position(double in_records_read,
51
table_map in_ref_depend_map)
53
records_read(in_records_read),
54
read_time(in_read_time),
57
ref_depend_map(in_ref_depend_map)
61
* Determine whether the table this particular position is representing in
62
* the query plan is a const table or not. A constant table is defined as
63
* (taken from the MySQL optimizer internals document on MySQL forge):
65
* 1) A table with zero rows, or with only one row
66
* 2) A table expression that is restricted with a WHERE condition
68
* Based on the definition above, when records_read is set to 1.0 in the
69
* Position class, it infers that this position in the partial plan
70
* represents a const table.
72
* @return true if this position represents a const table; false otherwise
74
bool isConstTable() const
76
return (records_read < 2.0);
79
double getFanout() const
84
void setFanout(double in_records_read)
86
records_read= in_records_read;
89
double getCost() const
94
JoinTable *getJoinTable()
100
* Check to see if the table attached to the JoinTable for this position
101
* has an index that can produce an ordering.
103
* @return true if the table attached to the JoinTable for this position
104
* does not have an index that can produce an ordering; false otherwise
106
bool hasTableForSorting(Table *cmp_table) const
108
return (cmp_table != table->table);
111
bool examinePosition(table_map found_ref)
113
if (table->table->map & found_ref)
125
table_map getRefDependMap()
127
return ref_depend_map;
130
void clearRefDependMap()
138
The "fanout": number of output rows that will be produced (after
139
pushed down selection condition is applied) per each row combination of
140
previous tables. The value is an in-precise estimate.
145
Cost accessing the table in course of the entire complete join execution,
146
i.e. cost of one access method use (e.g. 'range' or 'ref' scan ) times
147
number the access method will be invoked.
154
NULL - 'index' or 'range' or 'index_merge' or 'ALL' access is used.
155
Other - [eq_]ref[_or_null] access is used. Pointer to {t.keypart1 = expr}
159
/** If ref-based access is used: bitmap of tables this table depends on */
160
table_map ref_depend_map;
164
} /* end namespace optimizer */
166
} /* end namespace drizzled */
168
#endif /* DRIZZLED_OPTIMIZER_POSITION_H */