diff options
author | Alexander Barkov <bar@mariadb.com> | 2020-08-24 09:17:47 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2020-08-24 09:17:47 +0400 |
commit | 04ce29354b6053f0334ad1b8d5acaa0974b10fd8 (patch) | |
tree | 5ca7a164e985ac4f23fa006ab670162833304344 /sql/field.cc | |
parent | 2e5d86f49e7ee538806fba68dc8c960d6acdd483 (diff) | |
download | mariadb-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/field.cc')
-rw-r--r-- | sql/field.cc | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/sql/field.cc b/sql/field.cc index bac5dd95b5a..4a82eae6a0e 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5818,9 +5818,7 @@ Item *Field_temporal::get_equal_const_item_datetime(THD *thd, See comments about truncation in the same place in Field_time::get_equal_const_item(). */ - return new (thd->mem_root) Item_datetime_literal(thd, - dt.get_mysql_time(), - decimals()); + return new (thd->mem_root) Item_datetime_literal(thd, &dt, decimals()); } break; case ANY_SUBST: @@ -5832,7 +5830,7 @@ Item *Field_temporal::get_equal_const_item_datetime(THD *thd, if (!dt.is_valid_datetime()) return NULL; return new (thd->mem_root) - Item_datetime_literal_for_invalid_dates(thd, dt.get_mysql_time(), + Item_datetime_literal_for_invalid_dates(thd, &dt, dt.get_mysql_time()-> second_part ? TIME_SECOND_PART_DIGITS : 0); @@ -6183,7 +6181,7 @@ Item *Field_time::get_equal_const_item(THD *thd, const Context &ctx, (assuming CURRENT_DATE is '2015-08-30' */ - return new (thd->mem_root) Item_time_literal(thd, tm.get_mysql_time(), + return new (thd->mem_root) Item_time_literal(thd, &tm, tm.get_mysql_time()-> second_part ? TIME_SECOND_PART_DIGITS : @@ -6212,8 +6210,7 @@ Item *Field_time::get_equal_const_item(THD *thd, const Context &ctx, decimals()); if (!tm.is_valid_time()) return NULL; - return new (thd->mem_root) Item_time_literal(thd, tm.get_mysql_time(), - decimals()); + return new (thd->mem_root) Item_time_literal(thd, &tm, decimals()); } break; } @@ -6772,12 +6769,12 @@ Item *Field_newdate::get_equal_const_item(THD *thd, const Context &ctx, */ if (!dt.hhmmssff_is_zero()) return new (thd->mem_root) - Item_datetime_literal_for_invalid_dates(thd, dt.get_mysql_time(), + Item_datetime_literal_for_invalid_dates(thd, &dt, dt.get_mysql_time()-> second_part ? TIME_SECOND_PART_DIGITS : 0); - return new (thd->mem_root) - Item_date_literal_for_invalid_dates(thd, Date(&dt).get_mysql_time()); + Date d(&dt); + return new (thd->mem_root) Item_date_literal_for_invalid_dates(thd, &d); } break; case IDENTITY_SUBST: @@ -6792,8 +6789,8 @@ Item *Field_newdate::get_equal_const_item(THD *thd, const Context &ctx, Datetime dt(thd, const_item, Datetime::Options(TIME_CONV_NONE, thd)); if (!dt.is_valid_datetime()) return NULL; - return new (thd->mem_root) - Item_date_literal(thd, Date(&dt).get_mysql_time()); + Date d(&dt); + return new (thd->mem_root) Item_date_literal(thd, &d); } break; } |