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:
@ -1722,6 +1722,11 @@ public:
|
||||
{
|
||||
return is_valid_time() ? Temporal::to_packed() : 0;
|
||||
}
|
||||
longlong valid_time_to_packed() const
|
||||
{
|
||||
DBUG_ASSERT(is_valid_time_slow());
|
||||
return Temporal::to_packed();
|
||||
}
|
||||
long fraction_remainder(uint dec) const
|
||||
{
|
||||
DBUG_ASSERT(is_valid_time());
|
||||
@ -1896,6 +1901,11 @@ public:
|
||||
{
|
||||
return ::check_date_with_warn(thd, this, flags, MYSQL_TIMESTAMP_ERROR);
|
||||
}
|
||||
bool check_date_with_warn(THD *thd)
|
||||
{
|
||||
return ::check_date_with_warn(thd, this, Temporal::sql_mode_for_dates(thd),
|
||||
MYSQL_TIMESTAMP_ERROR);
|
||||
}
|
||||
static date_conv_mode_t comparison_flags_for_get_date()
|
||||
{ return TIME_INVALID_DATES | TIME_FUZZY_DATES; }
|
||||
};
|
||||
@ -1964,11 +1974,37 @@ public:
|
||||
datetime_to_date(this);
|
||||
DBUG_ASSERT(is_valid_date_slow());
|
||||
}
|
||||
explicit Date(const Temporal_hybrid *from)
|
||||
{
|
||||
*(static_cast<MYSQL_TIME*>(this))= *from;
|
||||
DBUG_ASSERT(is_valid_date_slow());
|
||||
}
|
||||
bool is_valid_date() const
|
||||
{
|
||||
DBUG_ASSERT(is_valid_value_slow());
|
||||
return time_type == MYSQL_TIMESTAMP_DATE;
|
||||
}
|
||||
bool check_date(date_conv_mode_t flags, int *warnings) const
|
||||
{
|
||||
DBUG_ASSERT(is_valid_date_slow());
|
||||
return ::check_date(this, (year || month || day),
|
||||
ulonglong(flags & TIME_MODE_FOR_XXX_TO_DATE),
|
||||
warnings);
|
||||
}
|
||||
bool check_date(THD *thd, int *warnings) const
|
||||
{
|
||||
return check_date(Temporal::sql_mode_for_dates(thd), warnings);
|
||||
}
|
||||
bool check_date(date_conv_mode_t flags) const
|
||||
{
|
||||
int dummy; /* unused */
|
||||
return check_date(flags, &dummy);
|
||||
}
|
||||
bool check_date(THD *thd) const
|
||||
{
|
||||
int dummy;
|
||||
return check_date(Temporal::sql_mode_for_dates(thd), &dummy);
|
||||
}
|
||||
const MYSQL_TIME *get_mysql_time() const
|
||||
{
|
||||
DBUG_ASSERT(is_valid_date_slow());
|
||||
@ -2011,6 +2047,11 @@ public:
|
||||
return Temporal_with_date::yearweek(week_behaviour);
|
||||
}
|
||||
|
||||
longlong valid_date_to_packed() const
|
||||
{
|
||||
DBUG_ASSERT(is_valid_date_slow());
|
||||
return Temporal::to_packed();
|
||||
}
|
||||
longlong to_longlong() const
|
||||
{
|
||||
return is_valid_date() ? (longlong) TIME_to_ulonglong_date(this) : 0LL;
|
||||
@ -2197,6 +2238,16 @@ public:
|
||||
{
|
||||
round(thd, dec, time_round_mode_t(fuzzydate), warn);
|
||||
}
|
||||
explicit Datetime(const Temporal_hybrid *from)
|
||||
{
|
||||
*(static_cast<MYSQL_TIME*>(this))= *from;
|
||||
DBUG_ASSERT(is_valid_datetime_slow());
|
||||
}
|
||||
explicit Datetime(const MYSQL_TIME *from)
|
||||
{
|
||||
*(static_cast<MYSQL_TIME*>(this))= *from;
|
||||
DBUG_ASSERT(is_valid_datetime_slow());
|
||||
}
|
||||
|
||||
bool is_valid_datetime() const
|
||||
{
|
||||
@ -2219,6 +2270,10 @@ public:
|
||||
int dummy; /* unused */
|
||||
return check_date(flags, &dummy);
|
||||
}
|
||||
bool check_date(THD *thd) const
|
||||
{
|
||||
return check_date(Temporal::sql_mode_for_dates(thd));
|
||||
}
|
||||
bool hhmmssff_is_zero() const
|
||||
{
|
||||
DBUG_ASSERT(is_valid_datetime_slow());
|
||||
@ -2327,6 +2382,11 @@ public:
|
||||
{
|
||||
return is_valid_datetime() ? Temporal::to_packed() : 0;
|
||||
}
|
||||
longlong valid_datetime_to_packed() const
|
||||
{
|
||||
DBUG_ASSERT(is_valid_datetime_slow());
|
||||
return Temporal::to_packed();
|
||||
}
|
||||
long fraction_remainder(uint dec) const
|
||||
{
|
||||
DBUG_ASSERT(is_valid_datetime());
|
||||
|
Reference in New Issue
Block a user