Commit 698aed2e authored by Michael Widenius's avatar Michael Widenius

Speedup:

- Don't call update_virtual_fields() if table->vfield is not set
- Don't prealloc memory for in open_tables() as this is very seldom used.


sql/records.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_base.cc:
  Don't prealloc memory for in open_tables() as this is very seldom used.
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_delete.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_handler.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_join_cache.cc:
  Don't call update_virtual_fields() if table->vfield is not set
  Move some frequent values to local variables
sql/sql_table.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/sql_update.cc:
  Don't call update_virtual_fields() if table->vfield is not set
sql/table.cc:
  Assert if update_virtual_fields is called with wrong parameters
parent e6c3d2ba
......@@ -401,7 +401,7 @@ int rr_sequential(READ_RECORD *info)
break;
}
}
if (!tmp)
if (!tmp && info->table->vfield)
update_virtual_fields(info->thd, info->table);
return tmp;
}
......
......@@ -4706,7 +4706,7 @@ int open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags)
temporary mem_root for new .frm parsing.
TODO: variables for size
*/
init_sql_alloc(&new_frm_mem, 8024, 8024);
init_sql_alloc(&new_frm_mem, 8024, 0);
thd->current_tablenr= 0;
restart:
......@@ -8648,14 +8648,9 @@ fill_record(THD * thd, List<Item> &fields, List<Item> &values,
}
/* Update virtual fields*/
thd->abort_on_warning= FALSE;
if (vcol_table)
{
if (vcol_table->vfield)
{
if (update_virtual_fields(thd, vcol_table, TRUE))
if (vcol_table && vcol_table->vfield &&
update_virtual_fields(thd, vcol_table, TRUE))
goto err;
}
}
thd->abort_on_warning= save_abort_on_warning;
thd->no_errors= save_no_errors;
DBUG_RETURN(thd->is_error());
......
......@@ -332,6 +332,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
while (!(error=info.read_record(&info)) && !thd->killed &&
! thd->is_error())
{
if (table->vfield)
update_virtual_fields(thd, table);
thd->examined_row_count++;
// thd->is_error() is tested to disallow delete row on error
......
......@@ -827,6 +827,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
goto ok;
}
/* Generate values for virtual fields */
if (table->vfield)
update_virtual_fields(thd, table);
if (cond && !cond->val_int())
continue;
......
......@@ -3344,23 +3344,26 @@ int JOIN_TAB_SCAN::next()
int skip_rc;
READ_RECORD *info= &join_tab->read_record;
SQL_SELECT *select= join_tab->cache_select;
TABLE *table= join_tab->table;
THD *thd= join->thd;
if (is_first_record)
is_first_record= FALSE;
else
err= info->read_record(info);
if (!err)
update_virtual_fields(join->thd, join_tab->table);
while (!err && select && (skip_rc= select->skip_record(join->thd)) <= 0)
if (!err && table->vfield)
update_virtual_fields(thd, table);
while (!err && select && (skip_rc= select->skip_record(thd)) <= 0)
{
if (join->thd->killed || skip_rc < 0)
if (thd->killed || skip_rc < 0)
return 1;
/*
Move to the next record if the last retrieved record does not
meet the condition pushed to the table join_tab.
*/
err= info->read_record(info);
if (!err)
update_virtual_fields(join->thd, join_tab->table);
if (!err && table->vfield)
update_virtual_fields(thd, table);
}
return err;
}
......@@ -3874,6 +3877,7 @@ int JOIN_TAB_SCAN_MRR::next()
*/
DBUG_ASSERT(cache->buff <= (uchar *) (*ptr) &&
(uchar *) (*ptr) <= cache->end_pos);
if (join_tab->table->vfield)
update_virtual_fields(join->thd, join_tab->table);
}
return rc;
......
......@@ -8078,6 +8078,7 @@ copy_data_between_tables(THD *thd, TABLE *from,TABLE *to,
error= 1;
break;
}
if (from->vfield)
update_virtual_fields(thd, from);
thd->row_count++;
if (++thd->progress.counter >= time_to_report_progress)
......@@ -8106,6 +8107,7 @@ copy_data_between_tables(THD *thd, TABLE *from,TABLE *to,
copy_ptr->do_copy(copy_ptr);
}
prev_insert_id= to->file->next_insert_id;
if (to->vfield)
update_virtual_fields(thd, to, TRUE);
if (thd->is_error())
{
......
......@@ -506,6 +506,7 @@ int mysql_update(THD *thd,
while (!(error=info.read_record(&info)) && !thd->killed)
{
if (table->vfield)
update_virtual_fields(thd, table);
thd->examined_row_count++;
if (!select || (error= select->skip_record(thd)) > 0)
......@@ -621,6 +622,7 @@ int mysql_update(THD *thd,
while (!(error=info.read_record(&info)) && !thd->killed)
{
if (table->vfield)
update_virtual_fields(thd, table);
thd->examined_row_count++;
if (!select || select->skip_record(thd) > 0)
......
......@@ -5759,8 +5759,7 @@ int update_virtual_fields(THD *thd, TABLE *table, bool for_write)
DBUG_ENTER("update_virtual_fields");
Field **vfield_ptr, *vfield;
int error __attribute__ ((unused))= 0;
if (!table || !table->vfield)
DBUG_RETURN(0);
DBUG_ASSERT(table && table->vfield);
thd->reset_arena_for_cached_items(table->expr_arena);
/* Iterate over virtual fields in the table */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment