[MDEV-24908] Execution time of JSON_MERGE depends heavily on the length of JSON values in the merged document Created: 2021-02-17  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: JSON
Affects Version/s: 10.2, 10.3, 10.4, 10.5, 10.6
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Minor
Reporter: Elena Stepanova Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: None


 Description   

The speed of JSON_MERGE_PATCH and synonyms depends significantly on the length of values in the merged JSON document, even if the values are not merged with anything. I suppose it is worth checking whether it is an expected effect.

drop table if exists t;
create table t (f_1 JSON, f_100 JSON, f_10000 JSON) engine=MyISAM;
insert into t values ('{"x":"a"}',CONCAT('{"x":"',REPEAT('a',100),'"}'),CONCAT('{"x":"',REPEAT('a',10000),'"}'));
 
SELECT BENCHMARK(100000,JSON_MERGE_PATCH( f_1, '{}' )) from t;
SELECT BENCHMARK(100000,JSON_MERGE_PATCH( f_100, '{}' )) from t;
SELECT BENCHMARK(100000,JSON_MERGE_PATCH( f_10000, '{}' )) from t;

10.2 067465cd

MariaDB [test]> SELECT BENCHMARK(100000,JSON_MERGE_PATCH( f_1, '{}' )) from t;
+-------------------------------------------------+
| BENCHMARK(100000,JSON_MERGE_PATCH( f_1, '{}' )) |
+-------------------------------------------------+
1 row in set (0.030 sec)
 
MariaDB [test]> SELECT BENCHMARK(100000,JSON_MERGE_PATCH( f_100, '{}' )) from t;
+---------------------------------------------------+
| BENCHMARK(100000,JSON_MERGE_PATCH( f_100, '{}' )) |
+---------------------------------------------------+
1 row in set (0.062 sec)
 
MariaDB [test]> SELECT BENCHMARK(100000,JSON_MERGE_PATCH( f_10000, '{}' )) from t;
+-----------------------------------------------------+
| BENCHMARK(100000,JSON_MERGE_PATCH( f_10000, '{}' )) |
+-----------------------------------------------------+
1 row in set (3.778 sec)

Reproducible on 10.2-10.6.
MySQL 5.7, 8.0 have the similar effect.


Generated at Thu Feb 08 09:33:38 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.