1
0
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:
Alexander Barkov
2020-08-24 09:17:47 +04:00
parent 2e5d86f49e
commit 04ce29354b
8 changed files with 207 additions and 82 deletions

View File

@ -10082,11 +10082,6 @@ int finalize_schema_table(st_plugin_int *plugin)
DBUG_RETURN(0);
}
/*
This is used to create a timestamp field
*/
MYSQL_TIME zero_time={ 0,0,0,0,0,0,0,0, MYSQL_TIMESTAMP_TIME };
/**
Output trigger information (SHOW CREATE TRIGGER) to the client.
@ -10171,8 +10166,9 @@ static bool show_create_trigger_impl(THD *thd, Trigger *trigger)
MY_CS_NAME_SIZE),
mem_root);
static const Datetime zero_datetime(Datetime::zero());
Item_datetime_literal *tmp= (new (mem_root)
Item_datetime_literal(thd, &zero_time, 2));
Item_datetime_literal(thd, &zero_datetime, 2));
tmp->set_name(thd, STRING_WITH_LEN("Created"), system_charset_info);
fields.push_back(tmp, mem_root);