1
Incorrect datetime format when using $NOW with mariadb
Source: directus/directus#24878 · opened by @SeanDylanGoff
Describe the Bug
Queries using $NOW (in my case filter with field _gt $NOW) lead to the following mariadb warning:
Truncated incorrect datetime value: '2023-05-16T22:33:06.412Z'
while this doesn't seem too serious it actually causes very slow queries in some specific cases.
To Reproduce
start directus with mariadb, filter a sufficiently large table (mine has 30k items) using $NOW. Simultaneously run show full processlist;.
You will notice a long running query like select table.id, ... from table where ((table.time_field > '2023-05-19T13:26:00.087Z')).
This query will generate a warning when run manually, and run very slow.
The issue seems to be the trailing "Z" as removing it leads to a speedup of 1000x (5s to 5ms) in my case.
Directus Version
v9.21.0 (can test on 10 in 1-2 days)
Hosting Strategy
Self-Hosted (Docker Image)
Queries using $NOW (in my case filter with field _gt $NOW) lead to the following mariadb warning:
Truncated incorrect datetime value: '2023-05-16T22:33:06.412Z'
while this doesn't seem too serious it actually causes very slow queries in some specific cases.
To Reproduce
start directus with mariadb, filter a sufficiently large table (mine has 30k items) using $NOW. Simultaneously run show full processlist;.
You will notice a long running query like select table.id, ... from table where ((table.time_field > '2023-05-19T13:26:00.087Z')).
This query will generate a warning when run manually, and run very slow.
The issue seems to be the trailing "Z" as removing it leads to a speedup of 1000x (5s to 5ms) in my case.
Directus Version
v9.21.0 (can test on 10 in 1-2 days)
Hosting Strategy
Self-Hosted (Docker Image)
No pledges yet. Be the first to back this.
Comments
Similar requests
Duration Picker
12 votes · 0 comments
Add an 'Apply' button to the 'Datetime' field Date/Time selector
1 vote · 0 comments
Allow configuring timezone in datetime display
3 votes · 0 comments
Export Collection Items in .xlsx Format
46 votes · 0 comments
Add sequential identifiers to Flow log entries
1 vote · 0 comments
No comments yet.