summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2020-08-24 09:17:47 +0400
committerAlexander Barkov <bar@mariadb.com>2020-08-24 09:17:47 +0400
commit04ce29354b6053f0334ad1b8d5acaa0974b10fd8 (patch)
tree5ca7a164e985ac4f23fa006ab670162833304344 /sql/sql_select.cc
parent2e5d86f49e7ee538806fba68dc8c960d6acdd483 (diff)
downloadmariadb-git-04ce29354b6053f0334ad1b8d5acaa0974b10fd8.tar.gz
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.
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 19e36632f0c..7091ffc2c58 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -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);