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

JSON_DETAILED output unnecessarily verbose (Part Time project)

Details

    Description

      JSON_DETAILED function (https://mariadb.com/kb/en/library/json_detailed/ ) is described as

      Represents JSON in the most understandable way emphasizing nested structures.
      

      We now got a use case for it: Optimizer Trace output. Optimizer trace is too large to be copied in full, instead we use expressions like

      select 
      JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives')) 
      from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
      

      Our experience is that JSON_DETAILED has some room for improvement when it comes to the quality of automatic JSON formatting.

      Example:

      source mdev19160-data.sql
      mysql> select JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t200\G
      *************************** 1. row ***************************
      JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')): [
          
          {
              "range_scan_alternatives": 
              [
                  
                  {
                      "index": "a_b",
                      "ranges": 
                      [
                          "2 <= a <= 2 AND 4 <= b <= 4"
                      ],
                      "rowid_ordered": true,
                      "using_mrr": false,
                      "index_only": true,
                      "rows": 1,
                      "cost": 1.1752,
                      "chosen": true
                  }
              ],
              "analyzing_roworder_intersect": 
              {
                  "cause": "too few roworder scans"
              },
              "analyzing_index_merge_union": 
              [
              ]
          }
      ]
      

      Things to note:

      • empty lines at the start (right before/after the "range_scan_alternatives")
      • "analyzing_index_merge_union":[] occupies 3 lines where one would be sufficient.
      • the same goes for "ranges"

      One can look at the JSON pretty-printer that is used by EXPLAIN FORMAT=JSON and optimizer trace. It produces a better result (but it has room for improvement, too.)

      Extra: in MySQL, the function is called JSON_PRETTY. We should add ability to use this name as an alias.

      Attachments

        Issue Links

          Activity

            psergei Sergei Petrunia created issue -
            psergei Sergei Petrunia made changes -
            Field Original Value New Value
            Description JSON_DETAILED function (https://mariadb.com/kb/en/library/json_detailed/ ) is described as

            {noformat}
            Represents JSON in the most understandable way emphasizing nested structures.
            {noformat}

            We now got a use case for it: Optimizer Trace output. Optimizer trace is too large to be copied in full, instead we use expressions like
            {noformat}
            select
            JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
            from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
            {noformat}

            Our experience is that {{JSON_DETAILED}} has some room for improvement when it comes to the quality of automatic JSON formatting.

            Example:


            JSON_DETAILED function (https://mariadb.com/kb/en/library/json_detailed/ ) is described as

            {noformat}
            Represents JSON in the most understandable way emphasizing nested structures.
            {noformat}

            We now got a use case for it: Optimizer Trace output. Optimizer trace is too large to be copied in full, instead we use expressions like
            {noformat}
            select
            JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
            from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
            {noformat}

            Our experience is that {{JSON_DETAILED}} has some room for improvement when it comes to the quality of automatic JSON formatting.

            Example:
            {code}
            source mdev19160-data.sql
            mysql> select JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t200\G
            *************************** 1. row ***************************
            JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')): [
                
                {
                    "range_scan_alternatives":
                    [
                        
                        {
                            "index": "a_b",
                            "ranges":
                            [
                                "2 <= a <= 2 AND 4 <= b <= 4"
                            ],
                            "rowid_ordered": true,
                            "using_mrr": false,
                            "index_only": true,
                            "rows": 1,
                            "cost": 1.1752,
                            "chosen": true
                        }
                    ],
                    "analyzing_roworder_intersect":
                    {
                        "cause": "too few roworder scans"
                    },
                    "analyzing_index_merge_union":
                    [
                    ]
                }
            ]
            {code}

            Things to note:
            * empty lines at the start
            * {{"analyzing_index_merge_union":[]}} occupies 3 lines where one would be sufficient.
            * the same goes for "ranges"

            One can look at JSON pretty-printer that EXPLAIN FORMAT=JSON and optimizer trace use. It produces a better result.
            Perhaps, we should switch JSON_DETAILED to use it?
            psergei Sergei Petrunia made changes -
            Description JSON_DETAILED function (https://mariadb.com/kb/en/library/json_detailed/ ) is described as

            {noformat}
            Represents JSON in the most understandable way emphasizing nested structures.
            {noformat}

            We now got a use case for it: Optimizer Trace output. Optimizer trace is too large to be copied in full, instead we use expressions like
            {noformat}
            select
            JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
            from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
            {noformat}

            Our experience is that {{JSON_DETAILED}} has some room for improvement when it comes to the quality of automatic JSON formatting.

            Example:
            {code}
            source mdev19160-data.sql
            mysql> select JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t200\G
            *************************** 1. row ***************************
            JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')): [
                
                {
                    "range_scan_alternatives":
                    [
                        
                        {
                            "index": "a_b",
                            "ranges":
                            [
                                "2 <= a <= 2 AND 4 <= b <= 4"
                            ],
                            "rowid_ordered": true,
                            "using_mrr": false,
                            "index_only": true,
                            "rows": 1,
                            "cost": 1.1752,
                            "chosen": true
                        }
                    ],
                    "analyzing_roworder_intersect":
                    {
                        "cause": "too few roworder scans"
                    },
                    "analyzing_index_merge_union":
                    [
                    ]
                }
            ]
            {code}

            Things to note:
            * empty lines at the start
            * {{"analyzing_index_merge_union":[]}} occupies 3 lines where one would be sufficient.
            * the same goes for "ranges"

            One can look at JSON pretty-printer that EXPLAIN FORMAT=JSON and optimizer trace use. It produces a better result.
            Perhaps, we should switch JSON_DETAILED to use it?
            JSON_DETAILED function (https://mariadb.com/kb/en/library/json_detailed/ ) is described as

            {noformat}
            Represents JSON in the most understandable way emphasizing nested structures.
            {noformat}

            We now got a use case for it: Optimizer Trace output. Optimizer trace is too large to be copied in full, instead we use expressions like
            {noformat}
            select
            JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
            from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
            {noformat}

            Our experience is that {{JSON_DETAILED}} has some room for improvement when it comes to the quality of automatic JSON formatting.

            Example:
            {code}
            source mdev19160-data.sql
            mysql> select JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t200\G
            *************************** 1. row ***************************
            JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')): [
                
                {
                    "range_scan_alternatives":
                    [
                        
                        {
                            "index": "a_b",
                            "ranges":
                            [
                                "2 <= a <= 2 AND 4 <= b <= 4"
                            ],
                            "rowid_ordered": true,
                            "using_mrr": false,
                            "index_only": true,
                            "rows": 1,
                            "cost": 1.1752,
                            "chosen": true
                        }
                    ],
                    "analyzing_roworder_intersect":
                    {
                        "cause": "too few roworder scans"
                    },
                    "analyzing_index_merge_union":
                    [
                    ]
                }
            ]
            {code}

            Things to note:
            * empty lines at the start (right before/after the "range_scan_alternatives")
            * {{"analyzing_index_merge_union":[]}} occupies 3 lines where one would be sufficient.
            * the same goes for "ranges"

            One can look at JSON pretty-printer that EXPLAIN FORMAT=JSON and optimizer trace use. It produces a better result.
            Perhaps, we should switch JSON_DETAILED to use it?
            psergei Sergei Petrunia made changes -
            Attachment mdev19160-data.sql [ 47904 ]
            psergei Sergei Petrunia made changes -
            Fix Version/s 10.4 [ 22408 ]
            psergei Sergei Petrunia made changes -
            Assignee Varun Gupta [ varun ]
            psergei Sergei Petrunia made changes -
            psergei Sergei Petrunia added a comment - cc: holyfoot
            psergei Sergei Petrunia made changes -
            Summary DRAFT JSON_DETAILED output unnecessarily verbose JSON_DETAILED output unnecessarily verbose
            psergei Sergei Petrunia made changes -
            Description JSON_DETAILED function (https://mariadb.com/kb/en/library/json_detailed/ ) is described as

            {noformat}
            Represents JSON in the most understandable way emphasizing nested structures.
            {noformat}

            We now got a use case for it: Optimizer Trace output. Optimizer trace is too large to be copied in full, instead we use expressions like
            {noformat}
            select
            JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
            from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
            {noformat}

            Our experience is that {{JSON_DETAILED}} has some room for improvement when it comes to the quality of automatic JSON formatting.

            Example:
            {code}
            source mdev19160-data.sql
            mysql> select JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t200\G
            *************************** 1. row ***************************
            JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')): [
                
                {
                    "range_scan_alternatives":
                    [
                        
                        {
                            "index": "a_b",
                            "ranges":
                            [
                                "2 <= a <= 2 AND 4 <= b <= 4"
                            ],
                            "rowid_ordered": true,
                            "using_mrr": false,
                            "index_only": true,
                            "rows": 1,
                            "cost": 1.1752,
                            "chosen": true
                        }
                    ],
                    "analyzing_roworder_intersect":
                    {
                        "cause": "too few roworder scans"
                    },
                    "analyzing_index_merge_union":
                    [
                    ]
                }
            ]
            {code}

            Things to note:
            * empty lines at the start (right before/after the "range_scan_alternatives")
            * {{"analyzing_index_merge_union":[]}} occupies 3 lines where one would be sufficient.
            * the same goes for "ranges"

            One can look at JSON pretty-printer that EXPLAIN FORMAT=JSON and optimizer trace use. It produces a better result.
            Perhaps, we should switch JSON_DETAILED to use it?
            JSON_DETAILED function (https://mariadb.com/kb/en/library/json_detailed/ ) is described as

            {noformat}
            Represents JSON in the most understandable way emphasizing nested structures.
            {noformat}

            We now got a use case for it: Optimizer Trace output. Optimizer trace is too large to be copied in full, instead we use expressions like
            {noformat}
            select
            JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
            from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
            {noformat}

            Our experience is that {{JSON_DETAILED}} has some room for improvement when it comes to the quality of automatic JSON formatting.

            Example:
            {code}
            source mdev19160-data.sql
            mysql> select JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t200\G
            *************************** 1. row ***************************
            JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')): [
                
                {
                    "range_scan_alternatives":
                    [
                        
                        {
                            "index": "a_b",
                            "ranges":
                            [
                                "2 <= a <= 2 AND 4 <= b <= 4"
                            ],
                            "rowid_ordered": true,
                            "using_mrr": false,
                            "index_only": true,
                            "rows": 1,
                            "cost": 1.1752,
                            "chosen": true
                        }
                    ],
                    "analyzing_roworder_intersect":
                    {
                        "cause": "too few roworder scans"
                    },
                    "analyzing_index_merge_union":
                    [
                    ]
                }
            ]
            {code}

            Things to note:
            * empty lines at the start (right before/after the "range_scan_alternatives")
            * {{"analyzing_index_merge_union":[]}} occupies 3 lines where one would be sufficient.
            * the same goes for "ranges"

            One can look at the JSON pretty-printer that is used by EXPLAIN FORMAT=JSON and optimizer trace. It produces a better result (but it has room for improvement, too.)

            Perhaps, we should switch JSON_DETAILED to use it?
            psergei Sergei Petrunia made changes -
            Description JSON_DETAILED function (https://mariadb.com/kb/en/library/json_detailed/ ) is described as

            {noformat}
            Represents JSON in the most understandable way emphasizing nested structures.
            {noformat}

            We now got a use case for it: Optimizer Trace output. Optimizer trace is too large to be copied in full, instead we use expressions like
            {noformat}
            select
            JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
            from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
            {noformat}

            Our experience is that {{JSON_DETAILED}} has some room for improvement when it comes to the quality of automatic JSON formatting.

            Example:
            {code}
            source mdev19160-data.sql
            mysql> select JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t200\G
            *************************** 1. row ***************************
            JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')): [
                
                {
                    "range_scan_alternatives":
                    [
                        
                        {
                            "index": "a_b",
                            "ranges":
                            [
                                "2 <= a <= 2 AND 4 <= b <= 4"
                            ],
                            "rowid_ordered": true,
                            "using_mrr": false,
                            "index_only": true,
                            "rows": 1,
                            "cost": 1.1752,
                            "chosen": true
                        }
                    ],
                    "analyzing_roworder_intersect":
                    {
                        "cause": "too few roworder scans"
                    },
                    "analyzing_index_merge_union":
                    [
                    ]
                }
            ]
            {code}

            Things to note:
            * empty lines at the start (right before/after the "range_scan_alternatives")
            * {{"analyzing_index_merge_union":[]}} occupies 3 lines where one would be sufficient.
            * the same goes for "ranges"

            One can look at the JSON pretty-printer that is used by EXPLAIN FORMAT=JSON and optimizer trace. It produces a better result (but it has room for improvement, too.)

            Perhaps, we should switch JSON_DETAILED to use it?
            JSON_DETAILED function (https://mariadb.com/kb/en/library/json_detailed/ ) is described as

            {noformat}
            Represents JSON in the most understandable way emphasizing nested structures.
            {noformat}

            We now got a use case for it: Optimizer Trace output. Optimizer trace is too large to be copied in full, instead we use expressions like
            {noformat}
            select
            JSON_DETAILED(JSON_EXTRACT(trace, '$**.analyzing_range_alternatives'))
            from INFORMATION_SCHEMA.OPTIMIZER_TRACE;
            {noformat}

            Our experience is that {{JSON_DETAILED}} has some room for improvement when it comes to the quality of automatic JSON formatting.

            Example:
            {code}
            source mdev19160-data.sql
            mysql> select JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')) from t200\G
            *************************** 1. row ***************************
            JSON_DETAILED(JSON_EXTRACT(a, '$**.analyzing_range_alternatives')): [
                
                {
                    "range_scan_alternatives":
                    [
                        
                        {
                            "index": "a_b",
                            "ranges":
                            [
                                "2 <= a <= 2 AND 4 <= b <= 4"
                            ],
                            "rowid_ordered": true,
                            "using_mrr": false,
                            "index_only": true,
                            "rows": 1,
                            "cost": 1.1752,
                            "chosen": true
                        }
                    ],
                    "analyzing_roworder_intersect":
                    {
                        "cause": "too few roworder scans"
                    },
                    "analyzing_index_merge_union":
                    [
                    ]
                }
            ]
            {code}

            Things to note:
            * empty lines at the start (right before/after the "range_scan_alternatives")
            * {{"analyzing_index_merge_union":[]}} occupies 3 lines where one would be sufficient.
            * the same goes for "ranges"

            One can look at the JSON pretty-printer that is used by EXPLAIN FORMAT=JSON and optimizer trace. It produces a better result (but it has room for improvement, too.)

            Extra: in MySQL, the function is called JSON_PRETTY. We should add ability to use this name as an alias.
            robertbindar Robert Bindar made changes -
            Labels gsoc21
            Nimit2801 Nimit Savant added a comment -

            Hey @varun, I want to contribute to this issue.
            Can you provide me a link to, where this function is being implemented in the repo server

            Thank You!

            Nimit2801 Nimit Savant added a comment - Hey @varun, I want to contribute to this issue. Can you provide me a link to, where this function is being implemented in the repo server Thank You!
            julien.fritsch Julien Fritsch made changes -
            Assignee Varun Gupta [ varun ] Sergei Petrunia [ psergey ]
            Nimit2801 Nimit Savant added a comment -

            @Sergei Petrunia can you help me with this issue, and give me some more information about this issue. Thank You!

            Nimit2801 Nimit Savant added a comment - @Sergei Petrunia can you help me with this issue, and give me some more information about this issue. Thank You!
            serg Sergei Golubchik made changes -
            Labels gsoc21 beginner-friendly gsoc21
            robertbindar Robert Bindar added a comment -

            Hey Nimit2801! You can start from Create_func_json_detailed class from item_create.cc and Item_func_json_format class from item_jsonfunc.cc
            Tracing these will lead you to where the actual pretty-printing happens. Let us know if you have any questions and sorry for the late reply. Great to see you interested in MariaDB for GSoC21!

            psergey If there is anything you want to add or if you want Nimit2801 to tackle the proposed improvements in a particular order, feel free to step in.

            robertbindar Robert Bindar added a comment - Hey Nimit2801 ! You can start from Create_func_json_detailed class from item_create.cc and Item_func_json_format class from item_jsonfunc.cc Tracing these will lead you to where the actual pretty-printing happens. Let us know if you have any questions and sorry for the late reply. Great to see you interested in MariaDB for GSoC21! psergey If there is anything you want to add or if you want Nimit2801 to tackle the proposed improvements in a particular order, feel free to step in.
            Nimit2801 Nimit Savant added a comment - - edited

            Hey @robertbindar, thanks for answering the question.
            1. Can you please guide me on how to which way would be the best to debug the code in
            Visual Studio in Windows.
            2. Also this bug was originally generated in 10.4, how would be my approach to fix this bug for all other branches.
            Thank You

            Nimit2801 Nimit Savant added a comment - - edited Hey @robertbindar, thanks for answering the question. 1. Can you please guide me on how to which way would be the best to debug the code in Visual Studio in Windows. 2. Also this bug was originally generated in 10.4, how would be my approach to fix this bug for all other branches. Thank You
            robertbindar Robert Bindar added a comment -

            Hey Nimit2801!
            1. Have you seen this https://mariadb.com/kb/en/Building_MariaDB_on_Windows/? I can't help you too much on setting up the windows environment for MariaDB, If you get stuck, please ask on MariaDB Zulip channel, people using windows might be able to help.
            2. If the bug is tagged 10.4, this means that the earliest version of MariaDB where the bug could be reproduced is 10.4. Basically you create a patch for 10.4 and once it is merged in 10.4, it will be propagated upwards by someone to 10.5, 10.6

            Let me know if you have more questions. Also I encourage you to ask this type of questions in Zulip because there you have more visibility, this means faster and better answers most probably

            robertbindar Robert Bindar added a comment - Hey Nimit2801 ! 1. Have you seen this https://mariadb.com/kb/en/Building_MariaDB_on_Windows/? I can't help you too much on setting up the windows environment for MariaDB, If you get stuck, please ask on MariaDB Zulip channel, people using windows might be able to help. 2. If the bug is tagged 10.4, this means that the earliest version of MariaDB where the bug could be reproduced is 10.4. Basically you create a patch for 10.4 and once it is merged in 10.4, it will be propagated upwards by someone to 10.5, 10.6 Let me know if you have more questions. Also I encourage you to ask this type of questions in Zulip because there you have more visibility, this means faster and better answers most probably
            psergei Sergei Petrunia made changes -
            Labels beginner-friendly gsoc21 beginner-friendly gsoc21 optimizer
            psergei Sergei Petrunia made changes -
            Assignee Sergei Petrunia [ psergey ] Sergei Krivonos [ JIRAUSER49805 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 94219 ] MariaDB v4 [ 141237 ]
            psergei Sergei Petrunia made changes -
            Assignee Sergei Krivonos [ JIRAUSER49805 ]
            kai Kai added a comment -

            Hi, is there anyone working on this? If not, I would like to improve it.

            kai Kai added a comment - Hi, is there anyone working on this? If not, I would like to improve it.

            No, nobody is, please, feel free to do it

            serg Sergei Golubchik added a comment - No, nobody is, please, feel free to do it
            cvicentiu Vicențiu Ciorbaru made changes -
            Labels beginner-friendly gsoc21 optimizer beginner-friendly gsoc21 gsoc22 optimizer
            cvicentiu Vicențiu Ciorbaru made changes -
            Summary JSON_DETAILED output unnecessarily verbose JSON_DETAILED output unnecessarily verbose (Part Time project)
            lunar_land ziyitan made changes -
            Comment [ Hello! @Sergei Golubchik I am Tan Ziyi from Huazhong University of Science and Technology (HUST, China),
            a 1st computer graduate student
            I want to work on this issue
            Please guide me how to start working, looking forward to your reply!
            (I am trying to build this project) ]
            nayuta-yanagisawa Nayuta Yanagisawa (Inactive) made changes -
            Assignee Rucha Deodhar [ rucha174 ]
            rucha174 Rucha Deodhar made changes -
            Fix Version/s 10.4.28 [ 28509 ]
            Fix Version/s 10.4 [ 22408 ]
            Resolution Fixed [ 1 ]
            Status Open [ 1 ] Closed [ 6 ]
            rucha174 Rucha Deodhar added a comment - Patch (submitted as contribution): https://github.com/MariaDB/server/commit/111a752b968561b34a88f33052519cb989a8a90f
            danblack Daniel Black made changes -
            ralf.gebhardt Ralf Gebhardt made changes -
            Fix Version/s 10.6.12 [ 28513 ]
            Fix Version/s 10.5.19 [ 28511 ]

            People

              rucha174 Rucha Deodhar
              psergei Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              11 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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