mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
MDEV-23551 Performance degratation in temporal literals in 10.4
Problem: Queries like this showed performance degratation in 10.4 over 10.3: SELECT temporal_literal FROM t1; SELECT temporal_literal + 1 FROM t1; SELECT COUNT(*) FROM t1 WHERE temporal_column = temporal_literal; SELECT COUNT(*) FROM t1 WHERE temporal_column = string_literal; Fix: Replacing the universal member "MYSQL_TIME cached_time" in Item_temporal_literal to data type specific containers: - Date in Item_date_literal - Time in Item_time_literal - Datetime in Item_datetime_literal This restores the performance, and make it even better in some cases. See benchmark results in MDEV. Also, this change makes futher separations of Date, Time, Datetime from each other, which will make it possible not to derive them from a too heavy (40 bytes) MYSQL_TIME, and replace them to smaller data type specific containers.
This commit is contained in:
@ -722,8 +722,9 @@ bool vers_select_conds_t::init_from_sysvar(THD *thd)
|
||||
if (type != SYSTEM_TIME_UNSPECIFIED && type != SYSTEM_TIME_ALL)
|
||||
{
|
||||
DBUG_ASSERT(type == SYSTEM_TIME_AS_OF);
|
||||
Datetime dt(&in.ltime);
|
||||
start.item= new (thd->mem_root)
|
||||
Item_datetime_literal(thd, &in.ltime, TIME_SECOND_PART_DIGITS);
|
||||
Item_datetime_literal(thd, &dt, TIME_SECOND_PART_DIGITS);
|
||||
if (!start.item)
|
||||
return true;
|
||||
}
|
||||
@ -787,15 +788,17 @@ Item* period_get_condition(THD *thd, TABLE_LIST *table, SELECT_LEX *select,
|
||||
{
|
||||
case SYSTEM_TIME_UNSPECIFIED:
|
||||
case SYSTEM_TIME_HISTORY:
|
||||
{
|
||||
thd->variables.time_zone->gmt_sec_to_TIME(&max_time, TIMESTAMP_MAX_VALUE);
|
||||
max_time.second_part= TIME_MAX_SECOND_PART;
|
||||
curr= newx Item_datetime_literal(thd, &max_time, TIME_SECOND_PART_DIGITS);
|
||||
Datetime dt(&max_time);
|
||||
curr= newx Item_datetime_literal(thd, &dt, TIME_SECOND_PART_DIGITS);
|
||||
if (conds->type == SYSTEM_TIME_UNSPECIFIED)
|
||||
cond1= newx Item_func_eq(thd, conds->field_end, curr);
|
||||
else
|
||||
cond1= newx Item_func_lt(thd, conds->field_end, curr);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
case SYSTEM_TIME_AS_OF:
|
||||
cond1= newx Item_func_le(thd, conds->field_start, conds->start.item);
|
||||
cond2= newx Item_func_gt(thd, conds->field_end, conds->start.item);
|
||||
|
Reference in New Issue
Block a user