[Bug]: zonemap does not do const folding on some functions #12322
Labels
kind/bug
Something isn't working
severity/s1
High impact: Logical errors or data errors that must occur
Milestone
Is there an existing issue for the same bug?
Environment
Actual Behavior
The following query is extremely slow
mysql> select * from system.rawlog where timestamp > date_add(current_timestamp, interval -2 hour) and caller = 'client/client.go:221' limit 10;
mysql> explain select * from system.rawlog where timestamp > date_add(current_timestamp, interval -2 hour) and caller = 'client/client.go:221' limit 10;
+---------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+---------------------------------------------------------------------------------------------------------+
| Project |
| Limit: 10 |
| -> Table Scan on system.rawlog |
| Filter Cond: (rawlog.caller = 'client/client.go:221'), (cast(rawlog.timestamp AS TIMESTAMP) > ) |
+---------------------------------------------------------------------------------------------------------+
4 rows in set (0.34 sec)
On the other hand, the following, is correct folded.
mysql> explain select * from system.rawlog where timestamp > '2023-10-24 20:00:00' and caller like '%client/client%' limit 10;
+---------------------------------------------------------------------------------------------------------------------------+
| QUERY PLAN |
+---------------------------------------------------------------------------------------------------------------------------+
| Project |
| Limit: 10 |
| -> Table Scan on system.rawlog |
| Filter Cond: (rawlog.timestamp > cast('2023-10-24 20:00:00' AS DATETIME)), (rawlog.caller like '%client/client%') |
| Block Filter Cond: (rawlog.timestamp > cast('2023-10-24 20:00:00' AS DATETIME)) |
+---------------------------------------------------------------------------------------------------------------------------+
5 rows in set (0.38 sec)
mysql>
Expected Behavior
No response
Steps to Reproduce
No response
Additional information
No response
The text was updated successfully, but these errors were encountered: