1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-32148 Inefficient WHERE timestamp_column=datetime_const_expr

Changing the way how a the following conditions are evaluated:

    WHERE timestamp_column=datetime_const_expr

(for all comparison operators: =, <=>, <, >, <=, >=, <> and for NULLIF)

Before the change it was always performed as DATETIME.
That was not efficient, as involved per-row TIMESTAMP->DATETIME conversion
for timestamp_column. For example, in case of the SYSTEM time zone
it involved a localtime_r() call, which is known to be slow.

After the change it's performed as TIMESTAMP in many cases.
This allows to avoid per-row conversion, as it works the other way around:
datetime_const_expr is converted to TIMESTAMP once before the execution stage.

Note, datetime_const_expr must be inside monotone continuous periods of
the current time zone, i.e. not near these anomalies:
- DST changes (spring forward, fall back)
- leap seconds
This commit is contained in:
Alexander Barkov
2023-09-12 11:27:54 +04:00
parent af4f9daeb8
commit 351a8eecf0
23 changed files with 1543 additions and 24 deletions

View File

@ -4283,6 +4283,8 @@ public:
utime_after_query= current_utime();
}
Timeval_null safe_timeval_replacement_for_nonzero_datetime(const Datetime &);
/**
Update server status after execution of a top level statement.
Currently only checks if a query was slow, and assigns