MySQL query timing out only with specific column selected and WHERE JSON_CONTAINS()

138 Views Asked by At

Consider the following queries:

SELECT uID, name FROM table WHERE JSON_CONTAINS(email, '{"key": "[email protected]"}', '$');
SELECT uID, name, history FROM table WHERE JSON_CONTAINS(email, '{"key": "[email protected]"}', '$');
SELECT uID, name, history FROM table WHERE uID = 1;

uID, name, and history columns are INT(10), JSON, and JSON datatypes, respectively. email column is also JSON datatype.

Queries 1 and 3 both complete in a moment. Query 2 times out after 30 seconds (Error Code: 2013. Lost connection to MySQL server during query).

My question is this: Why is it that combining a SELECT history and WHERE JSON_CONTAINS causes a timeout, whereas having either or in the query is fine?

0

There are 0 best solutions below