~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/optimizer/access_method/scan.cc

  • Committer: Monty Taylor
  • Date: 2010-04-27 21:03:13 UTC
  • mto: This revision was merged to the branch mainline in revision 1510.
  • Revision ID: mordred@inaugust.com-20100427210313-6h4uz2553kapi196
Undid the libdrizzled.so.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include <config.h>
22
 
#include <drizzled/session.h>
23
 
#include <drizzled/join_table.h>
24
 
#include <drizzled/table.h>
25
 
#include <drizzled/sql_select.h>
26
 
#include <drizzled/internal/my_sys.h>
27
 
#include <drizzled/optimizer/access_method/scan.h>
 
21
#include "config.h"
 
22
#include "drizzled/session.h"
 
23
#include "drizzled/join_table.h"
 
24
#include "drizzled/table.h"
 
25
#include "drizzled/sql_select.h"
 
26
#include "drizzled/internal/my_sys.h"
 
27
#include "drizzled/optimizer/access_method/scan.h"
28
28
 
29
29
using namespace drizzled;
30
30
 
31
 
static uint32_t make_join_orderinfo(Join *join);
 
31
static uint32_t make_join_orderinfo(JOIN *join);
32
32
 
33
33
bool optimizer::Scan::getStats(Table *table,
34
34
                               JoinTable *join_tab)
35
35
{
36
 
  Join *join= join_tab->join;
 
36
  JOIN *join= join_tab->join;
37
37
  bool statistics= test(! (join->select_options & SELECT_DESCRIBE));
38
38
  uint64_t options= (join->select_options &
39
39
                     (SELECT_DESCRIBE | SELECT_NO_JOIN_CACHE)) |
70
70
    join_tab->read_first_record= join_init_quick_read_record;
71
71
    if (statistics)
72
72
    {
73
 
      join->session->status_var.select_range_check_count++;
 
73
      status_var_increment(join->session->status_var.select_range_check_count);
74
74
    }
75
75
  }
76
76
  else
82
82
      {
83
83
        if (statistics)
84
84
        {
85
 
          join->session->status_var.select_range_count++;
 
85
          status_var_increment(join->session->status_var.select_range_count);
86
86
        }
87
87
      }
88
88
      else
90
90
        join->session->server_status|= SERVER_QUERY_NO_INDEX_USED;
91
91
        if (statistics)
92
92
        {
93
 
          join->session->status_var.select_scan_count++;
 
93
          status_var_increment(join->session->status_var.select_scan_count);
94
94
        }
95
95
      }
96
96
    }
100
100
      {
101
101
        if (statistics)
102
102
        {
103
 
          join->session->status_var.select_full_range_join_count++;
 
103
          status_var_increment(join->session->status_var.select_full_range_join_count);
104
104
        }
105
105
      }
106
106
      else
108
108
        join->session->server_status|= SERVER_QUERY_NO_INDEX_USED;
109
109
        if (statistics)
110
110
        {
111
 
          join->session->status_var.select_full_join_count++;
 
111
          status_var_increment(join->session->status_var.select_full_join_count);
112
112
        }
113
113
      }
114
114
    }
131
131
             See bug #26447: "Using the clustered index for a table scan
132
132
             is always faster than using a secondary index".
133
133
           */
134
 
          if (table->getShare()->hasPrimaryKey() &&
 
134
          if (table->s->primary_key != MAX_KEY &&
135
135
              table->cursor->primary_key_is_clustered())
136
136
          {
137
 
            join_tab->index= table->getShare()->getPrimaryKey();
 
137
            join_tab->index= table->s->primary_key;
138
138
          }
139
139
          else
140
140
          {
146
146
      }
147
147
    }
148
148
  }
149
 
 
150
149
  return false;
151
150
}
152
151
 
159
158
  ordered. If there is a temp table the ordering is done as a last
160
159
  operation and doesn't prevent join cache usage.
161
160
*/
162
 
static uint32_t make_join_orderinfo(Join *join)
 
161
static uint32_t make_join_orderinfo(JOIN *join)
163
162
{
164
163
  uint32_t i= 0;
165
164
  if (join->need_tmp)