~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/opt_range.cc

Merge Nathan

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
 
116
116
#include <string>
117
117
#include <vector>
 
118
#include <algorithm>
118
119
 
119
120
using namespace std;
120
121
 
2334
2335
    group_trp= get_best_group_min_max(&param, tree);
2335
2336
    if (group_trp)
2336
2337
    {
2337
 
      param.table->quick_condition_rows= cmin(group_trp->records,
 
2338
      param.table->quick_condition_rows= min(group_trp->records,
2338
2339
                                             head->file->stats.records);
2339
2340
      if (group_trp->read_cost < best_read_time)
2340
2341
      {
2627
2628
    {
2628
2629
      imerge_trp->read_cost= imerge_cost;
2629
2630
      imerge_trp->records= non_cpk_scan_records + cpk_scan_records;
2630
 
      imerge_trp->records= cmin(imerge_trp->records,
 
2631
      imerge_trp->records= min(imerge_trp->records,
2631
2632
                               param->table->file->stats.records);
2632
2633
      imerge_trp->range_scans= range_scans;
2633
2634
      imerge_trp->range_scans_end= range_scans + n_child_scans;
6274
6275
    }
6275
6276
  }
6276
6277
  seq->param->range_count++;
6277
 
  seq->param->max_key_part=cmax(seq->param->max_key_part,(uint32_t)key_tree->part);
 
6278
  seq->param->max_key_part= max(seq->param->max_key_part,(uint32_t)key_tree->part);
6278
6279
  return 0;
6279
6280
}
6280
6281
 
6361
6362
      param->table->quick_key_parts[keynr]=param->max_key_part+1;
6362
6363
      param->table->quick_n_ranges[keynr]= param->range_count;
6363
6364
      param->table->quick_condition_rows=
6364
 
        cmin(param->table->quick_condition_rows, rows);
 
6365
        min(param->table->quick_condition_rows, rows);
6365
6366
    }
6366
6367
  }
6367
6368
  /* Figure out if the key scan is ROR (returns rows in ROWID order) or not */
7394
7395
    last_range= *(cur_range++);
7395
7396
 
7396
7397
    start_key.key=    (const unsigned char*) last_range->min_key;
7397
 
    start_key.length= cmin(last_range->min_length, (uint16_t)prefix_length);
 
7398
    start_key.length= min(last_range->min_length, (uint16_t)prefix_length);
7398
7399
    start_key.keypart_map= last_range->min_keypart_map & keypart_map;
7399
7400
    start_key.flag=   ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY :
7400
7401
                       (last_range->flag & EQ_RANGE) ?
7401
7402
                       HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT);
7402
7403
    end_key.key=      (const unsigned char*) last_range->max_key;
7403
 
    end_key.length=   cmin(last_range->max_length, (uint16_t)prefix_length);
 
7404
    end_key.length=   min(last_range->max_length, (uint16_t)prefix_length);
7404
7405
    end_key.keypart_map= last_range->max_keypart_map & keypart_map;
7405
7406
    /*
7406
7407
      We use READ_AFTER_KEY here because if we are reading on a key
8177
8178
        cur_group_prefix_len+= cur_part->store_length;
8178
8179
        used_key_parts_map.set(key_part_nr);
8179
8180
        ++cur_group_key_parts;
8180
 
        max_key_part= cmax(max_key_part,key_part_nr);
 
8181
        max_key_part= max(max_key_part,key_part_nr);
8181
8182
      }
8182
8183
      /*
8183
8184
        Check that used key parts forms a prefix of the index.
8780
8781
    {
8781
8782
      double blocks_per_group= (double) num_blocks / (double) num_groups;
8782
8783
      p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
8783
 
      p_overlap= cmin(p_overlap, 1.0);
 
8784
      p_overlap= min(p_overlap, 1.0);
8784
8785
    }
8785
 
    io_cost= (double) cmin(num_groups * (1 + p_overlap), (double)num_blocks);
 
8786
    io_cost= (double) min(num_groups * (1 + p_overlap), (double)num_blocks);
8786
8787
  }
8787
8788
  else
8788
8789
    io_cost= (keys_per_group > keys_per_block) ?