Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-24908

Execution time of JSON_MERGE depends heavily on the length of JSON values in the merged document

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • 10.2, 10.3, 10.4, 10.5, 10.6
    • 10.4, 10.5
    • JSON
    • 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.

      Attachments

        Activity

          People

            rucha174 Rucha Deodhar
            elenst Elena Stepanova
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.