You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MySQL provides Multi-Valued Indexes to speed up JSON_CONTAINS() search. However, when the condition JSON_CONTAINS(“...”) = 1 is evaluated, MySQL must execute the function for each row to determine the outcome before it can apply the =1 condition.
This basically bypass the index, and makes query slow to a crawl on big tables.
Removing the "=1" will causes Doctrine to fails to parse the query, throwing a very non descriptive error "Warning: Attempt to read property "type" on null". Took me quite awhile to trace the problem to this library.
Going forward, can you disable the check for "=1"? This is redundant, as simply call JSON_CONTAINS(“...”) will use the index as expected, while also only return rows when this is implicitly true.
The text was updated successfully, but these errors were encountered:
HieuLeDuc
changed the title
MySQL: Explicit evaluation of JSON_CONTAINS() = 1 forces looping through all rows.
MySQL: Explicit evaluation of JSON_CONTAINS() = 1 forces looping through all rows, bypassing index.
May 17, 2024
Same for me. Unfortunately JSON_CONTAINS query on a table with a few mil rows takes up to 3 sec, whereas a query without the "= 1" part will utilize the index and will run in just a couple of ms. It's a huge performance issue for me.
@Hikariii do you have any idea of a temporary workaround that might help? Even if it would be a very ugly solution, I can live with that for some time. Do they have any PR or issue opened regarding this issue?
Hello, i found a bug in a pretty niche use case.
MySQL provides Multi-Valued Indexes to speed up JSON_CONTAINS() search. However, when the condition JSON_CONTAINS(“...”) = 1 is evaluated, MySQL must execute the function for each row to determine the outcome before it can apply the =1 condition.
This basically bypass the index, and makes query slow to a crawl on big tables.
Removing the "=1" will causes Doctrine to fails to parse the query, throwing a very non descriptive error "Warning: Attempt to read property "type" on null". Took me quite awhile to trace the problem to this library.
Going forward, can you disable the check for "=1"? This is redundant, as simply call JSON_CONTAINS(“...”) will use the index as expected, while also only return rows when this is implicitly true.
The text was updated successfully, but these errors were encountered: