summaryrefslogtreecommitdiff
path: root/sql/table.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/table.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/table.cc')
-rw-r--r--sql/table.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/sql/table.cc b/sql/table.cc
index ca0af28a79d..6fa2ef51f89 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -9365,7 +9365,8 @@ bool TR_table::query(MYSQL_TIME &commit_time, bool backwards)
SELECT_LEX &slex= *(thd->lex->first_select_lex());
Name_resolution_context_backup backup(slex.context, *this);
Item *field= newx Item_field(thd, &slex.context, (*this)[FLD_COMMIT_TS]);
- Item *value= newx Item_datetime_literal(thd, &commit_time, 6);
+ Datetime dt(&commit_time);
+ Item *value= newx Item_datetime_literal(thd, &dt, 6);
COND *conds;
if (backwards)
conds= newx Item_func_ge(thd, field, value);