~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/opt_range.cc

  • Committer: Stewart Smith
  • Date: 2009-07-02 17:18:18 UTC
  • mfrom: (1085 staging)
  • mto: This revision was merged to the branch mainline in revision 1089.
  • Revision ID: stewart@flamingspork.com-20090702171818-qrp4d403iw8tazlg
mergeĀ mainline

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;
6278
6279
    }
6279
6280
  }
6280
6281
  seq->param->range_count++;
6281
 
  seq->param->max_key_part=cmax(seq->param->max_key_part,(uint32_t)key_tree->part);
 
6282
  seq->param->max_key_part= max(seq->param->max_key_part,(uint32_t)key_tree->part);
6282
6283
  return 0;
6283
6284
}
6284
6285
 
6365
6366
      param->table->quick_key_parts[keynr]=param->max_key_part+1;
6366
6367
      param->table->quick_n_ranges[keynr]= param->range_count;
6367
6368
      param->table->quick_condition_rows=
6368
 
        cmin(param->table->quick_condition_rows, rows);
 
6369
        min(param->table->quick_condition_rows, rows);
6369
6370
    }
6370
6371
  }
6371
6372
  /* Figure out if the key scan is ROR (returns rows in ROWID order) or not */
7398
7399
    last_range= *(cur_range++);
7399
7400
 
7400
7401
    start_key.key=    (const unsigned char*) last_range->min_key;
7401
 
    start_key.length= cmin(last_range->min_length, (uint16_t)prefix_length);
 
7402
    start_key.length= min(last_range->min_length, (uint16_t)prefix_length);
7402
7403
    start_key.keypart_map= last_range->min_keypart_map & keypart_map;
7403
7404
    start_key.flag=   ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY :
7404
7405
                       (last_range->flag & EQ_RANGE) ?
7405
7406
                       HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT);
7406
7407
    end_key.key=      (const unsigned char*) last_range->max_key;
7407
 
    end_key.length=   cmin(last_range->max_length, (uint16_t)prefix_length);
 
7408
    end_key.length=   min(last_range->max_length, (uint16_t)prefix_length);
7408
7409
    end_key.keypart_map= last_range->max_keypart_map & keypart_map;
7409
7410
    /*
7410
7411
      We use READ_AFTER_KEY here because if we are reading on a key
8181
8182
        cur_group_prefix_len+= cur_part->store_length;
8182
8183
        used_key_parts_map.set(key_part_nr);
8183
8184
        ++cur_group_key_parts;
8184
 
        max_key_part= cmax(max_key_part,key_part_nr);
 
8185
        max_key_part= max(max_key_part,key_part_nr);
8185
8186
      }
8186
8187
      /*
8187
8188
        Check that used key parts forms a prefix of the index.
8784
8785
    {
8785
8786
      double blocks_per_group= (double) num_blocks / (double) num_groups;
8786
8787
      p_overlap= (blocks_per_group * (keys_per_subgroup - 1)) / keys_per_group;
8787
 
      p_overlap= cmin(p_overlap, 1.0);
 
8788
      p_overlap= min(p_overlap, 1.0);
8788
8789
    }
8789
 
    io_cost= (double) cmin(num_groups * (1 + p_overlap), (double)num_blocks);
 
8790
    io_cost= (double) min(num_groups * (1 + p_overlap), (double)num_blocks);
8790
8791
  }
8791
8792
  else
8792
8793
    io_cost= (keys_per_group > keys_per_block) ?