~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/join.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-08-10 22:30:11 UTC
  • mto: (1115.3.10 captain)
  • mto: This revision was merged to the branch mainline in revision 1120.
  • Revision ID: osullivan.padraig@gmail.com-20090810223011-ua3dwbt1h8z5atl7
Made the records_read member of the Position class private.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3105
3105
          is an inprecise estimate and adding 1 (or, in the worst case,
3106
3106
          #max_nested_outer_joins=64-1) will not make it any more precise.
3107
3107
      */
3108
 
      if (pos->records_read > DBL_EPSILON)
3109
 
        found*= pos->records_read;
 
3108
      if (pos->getFanout() > DBL_EPSILON)
 
3109
        found*= pos->getFanout();
3110
3110
    }
3111
3111
  }
3112
3112
  return found;
3170
3170
/** Save const tables first as used tables. */
3171
3171
static void set_position(JOIN *join,uint32_t idx,JoinTable *table,KeyUse *key)
3172
3172
{
3173
 
  Position tmp_pos;
3174
 
  tmp_pos.table= table;
3175
 
  tmp_pos.key= key;
3176
 
  tmp_pos.records_read= 1.0;  /* This is a const table */
3177
 
  tmp_pos.ref_depend_map= 0;
 
3173
  Position tmp_pos(1.0, /* This is a const table */
 
3174
                   0.0,
 
3175
                   table,
 
3176
                   key,
 
3177
                   0);
3178
3178
  join->setPosInPartialPlan(idx, tmp_pos);
3179
3179
 
3180
3180
  /* Move the const table as down as possible in best_ref */
3765
3765
  }
3766
3766
 
3767
3767
  /* Update the cost information for the current partial plan */
3768
 
  Position tmp_pos;
3769
 
  tmp_pos.records_read= records;
3770
 
  tmp_pos.read_time=    best;
3771
 
  tmp_pos.key=          best_key;
3772
 
  tmp_pos.table=        s;
3773
 
  tmp_pos.ref_depend_map= best_ref_depends_map;
 
3768
  Position tmp_pos(records,
 
3769
                   best,
 
3770
                   s,
 
3771
                   best_key,
 
3772
                   best_ref_depends_map);
3774
3773
  join->setPosInPartialPlan(idx, tmp_pos);
3775
3774
 
3776
3775
  if (!best_key &&
3819
3818
                     record_count, read_time);
3820
3819
    /* compute the cost of the new plan extended with 's' */
3821
3820
    partial_pos= join->getPosFromPartialPlan(idx);
3822
 
    record_count*= partial_pos.records_read;
 
3821
    record_count*= partial_pos.getFanout();
3823
3822
    read_time+=    partial_pos.read_time;
3824
3823
    join_tables&= ~(s->table->map);
3825
3824
    ++idx;
3967
3966
 
3968
3967
    /* compute the cost of the new plan extended with 'best_table' */
3969
3968
    Position partial_pos= join->getPosFromPartialPlan(idx);
3970
 
    record_count*= partial_pos.records_read;
 
3969
    record_count*= partial_pos.getFanout();
3971
3970
    read_time+=    partial_pos.read_time;
3972
3971
 
3973
3972
    remaining_tables&= ~(best_table->table->map);
4139
4138
                       record_count, read_time);
4140
4139
      /* Compute the cost of extending the plan with 's' */
4141
4140
      partial_pos= join->getPosFromPartialPlan(idx);
4142
 
      current_record_count= record_count * partial_pos.records_read;
 
4141
      current_record_count= record_count * partial_pos.getFanout();
4143
4142
      current_read_time=    read_time + partial_pos.read_time;
4144
4143
 
4145
4144
      /* Expand only partial plans with lower cost than the best QEP so far */
4502
4501
        tab->ref.key= -1;
4503
4502
        tab->ref.key_parts= 0;          // Don't use ref key.
4504
4503
        cur_pos= join->getPosFromOptimalPlan(i);
4505
 
        cur_pos.records_read= rows2double(tab->quick->records);
 
4504
        cur_pos.setFanout(rows2double(tab->quick->records));
4506
4505
        /*
4507
4506
           We will use join cache here : prevent sorting of the first
4508
4507
           table only and sort at the end.
4604
4603
          cur_pos= join->getPosFromOptimalPlan(i);
4605
4604
          if ((cond && (! ((tab->keys & tab->const_keys) == tab->keys) && i > 0)) ||
4606
4605
              (! tab->const_keys.none() && (i == join->const_tables) &&
4607
 
              (join->unit->select_limit_cnt < cur_pos.records_read) && ((join->select_options & OPTION_FOUND_ROWS) == false)))
 
4606
              (join->unit->select_limit_cnt < cur_pos.getFanout()) && ((join->select_options & OPTION_FOUND_ROWS) == false)))
4608
4607
          {
4609
4608
            /* Join with outer join condition */
4610
4609
            COND *orig_cond= sel->cond;
4650
4649
            if (sel->quick)
4651
4650
            {
4652
4651
              cur_pos= join->getPosFromOptimalPlan(i);
4653
 
              cur_pos.records_read= (double)sel->quick->records;
 
4652
              cur_pos.setFanout(static_cast<double>(sel->quick->records));
4654
4653
            }
4655
4654
          }
4656
4655
          else