O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using EXPLAIN JSON

Using the explain plan in JSON format gives complete information about the query execution:

mysql> EXPLAIN FORMAT=JSON SELECT dept_name FROM dept_emp JOIN employees ON dept_emp.emp_no=employees.emp_no JOIN departments ON departments.dept_no=dept_emp.dept_no WHERE employees.first_name='Aamer'\G*************************** 1. row ***************************EXPLAIN: {  "query_block": {    "select_id": 1,    "cost_info": {      "query_cost": "286.13"    },    "nested_loop": [      {        "table": {          "table_name": "employees",          "access_type": "ref",          "possible_keys": [            "PRIMARY",            "name"          ],          "key": "name",          "used_key_parts": [            "first_name"          ],          "key_length": "58",          "ref": [            "const"          ],          "rows_examined_per_scan": 228,          "rows_produced_per_join": 228, "filtered": "100.00", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required