← Back to team overview

maria-developers team mailing list archive

: GSoC Project Optimizer Trace

 

Hi Zhzhzoo,

Please find below some thoughts about the optimizer trace project

* The MDEV for the optimizer trace task is
https://jira.mariadb.org/browse/MDEV-6111. Let's keep it up to date with all
the changes.

* I think we should target MySQL-like functionality of optimizer_trace. At
least, for the first milestone. We may decide to make some things better 
but working in a similar way to MySQL is a nice first goal.

* MariaDB's optimizer trace will contain JSON and produce similar content to
MySQL. However, MariaDB's optimizer is different, so one cannot expect that
the JSON document will have exactly the same fields/objects/etc. (MariaDB' 
EXPLAIN FORMAT=JSON output doesn't match the one in MySQL, either. And in 
MySQL, the output varies across its versions.)

* MySQL prints conditions with heavy over-quoting.
Example:

 "original_condition": "((`A`.`a` = `B`.`a`) and ((`A`.`a` + `B`.`a`) < 10))",

MariaDB has the code to print the condition without redundant quotes (see
how EXPLAIN FORMAT=JSON does it).

* I assume MySQL has some class for printing well-formed JSON documents.
MariaDB also has one. It is in sql/my_json_writer.h, see class Json_writer.
It handles printing into JSON, and also does pretty-printing. When I looked at
the code last time, it did pretty-printing better than MySQL's code for EXPLAIN
FORMAT=JSON did.
It would be nice to use Json_writer for collecting optimizer trace output, too.
(there is a caveat: Json_writer was written specifically for producing 
EXPLAIN FORMAT=JSON output so it may lack some features. You may need to 
extend it).

BR
 Sergei
-- 
Sergei Petrunia, Software Developer
MariaDB Corporation | Skype: sergefp | Blog: http://s.petrunia.net/blog