Open harisenbon opened 1 year ago
Hi @harisenbon
Thanks for your request.
As for me, it looks a little bit weird that JSON_EXTRACT_STRING(
value, 'lccontent') = 'paid'
works much slower than JSON_MATCH_ANY(MATCH_PARAM_STRING_STRICT() LIKE '%paid%',
value, 'lccontent')
.
I would do some investigations before adding this feature.
@AdalbertMemSQL
As for me, it looks a little bit weird that it works much slower
Yeah, I thought so too ;)
I would love to use , JSON_EXTRACT_STRING
(as it gives some type casting benefits) but I have a month of tickets with support about how I should be using JSON_MATCH_ANY
instead.
I just had a chance to test this thing. Used 8.0.12 version of the SingleStore.
MySQL [db]> select * from t where JSON_EXTRACT_STRING(`value`, 'lccontent') = 'asdas';
Empty set (0.163 sec)
MySQL [db]> select * from t where JSON_MATCH_ANY(MATCH_PARAM_STRING_STRICT() LIKE 'asdas', `value`, 'lccontent');
Empty set (0.479 sec)
Looks like JSON_EXTRACT_STRING
worked ~3 times faster.
Then I tried bigger JSON values and the difference was not so significant, but even with very big JSON values, JSON_EXTRACT_STRING
is slightly faster.
MySQL [db]> select * from t where JSON_EXTRACT_STRING(`value`, 'lccontent') = 'asdas';
Empty set (1.525 sec)
MySQL [db]> select * from t where JSON_MATCH_ANY(MATCH_PARAM_STRING_STRICT() LIKE 'asdas', `value`, 'lccontent');
Empty set (1.873 sec)
@harisenbon Can you please clarify, what version of SingleStore are you using and what the schema/size of your JSON data is?
Probably, this performance degradation happens only in some specific cases.
Hey all,
I'm working with the S2 team, and we've run into huge performance issues when querying on multiple JSON fields in S2 (see Support ticket #27009)
Example:
With the JSON improvements in version 8, we can replace that with something like this, which runs at 1.25s without load:
However, the Laravel driver doesn't currently support
JSON_MATCH_ANY
out of the box.I've gotten it working on my system, using the following changes to
SingleStore\Laravel\Query\Grammar
Functions to determine if we should use this new code:
We then create a function to wrap the default query with
JSON_MATCH_ANY
, swapping inMATCH_PARAM_*
for the colum:Finally, we apply the override to each
where*
function that we want support for:Let me know if a PR would be preferred.