---
title: "Discussion on \"Database indexing -101 (Part 2)\" | Hashnode"
description: "Discussion on \"Database indexing -101 (Part 2)\". Learn how to optimise your MySQL query, the easy way."
url: "https://hashnode.com/posts/database-indexing-101-part-2/619f134ef015481b2669c71e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Database indexing -101 (Part 2)](https://sumanau.hashnode.dev/database-indexing-101-part-2?utm_source=hashnode&utm_medium=feed)

Learn how to optimise your MySQL query, the easy way.

Nov 25, 2021 · 9 min read · sumanau.hashnode.dev  
Read the article

-   [#databases](https://hashnode.com/tag/databases)
-   [#optimization](https://hashnode.com/tag/optimization)
-   [#mysql](https://hashnode.com/tag/mysql)
-   [#performance](https://hashnode.com/tag/performance)
-   [#sql](https://hashnode.com/tag/sql)

## Written by

[Sumanau Sareen](https://hashnode.com/@sumanau7)

@sumanau7

  
[View profile](https://hashnode.com/@sumanau7)

Engineer

## Responses 1

Markdown supported · ⌘↵ to post

[Aakar Sharma](https://hashnode.com/@AakarSharma)

[Nov 25, 2021](https://hashnode.com/posts/database-indexing-101-part-2/619f134ef015481b2669c71e/comment/619f2fddf015481b2669c9b9)

You could have used

```
explain format=json
```

which would have given you more info something like this

```
EXPLAIN: {
  "query_block": {
    "select_id": 1,
    "cost_info": {
      "query_cost": "16.72"
    },
    "nested_loop": [
      {
        "table": {
          "table_name": "departments",
          <skipped>
      },
      {
        "table": {
          "table_name": "<subquery2>",
          "access_type": "eq_ref",
          "key": "<auto_key>",
          "key_length": "4",
          "ref": [
            "employees.departments.dept_no"
          ],
          "rows_examined_per_scan": 1,
          "materialized_from_subquery": {
            "using_temporary_table": true,
            "query_block": {
              "table": {
                "table_name": "dept_manager",
                "access_type": "ALL",
                "possible_keys": [
                  "dept_no"
                ],
                "rows_examined_per_scan": 24,
                "rows_produced_per_join": 21,
                "filtered": "90.00",
                "cost_info": {
                  "read_cost": "1.48",
                  "eval_cost": "4.32",
                  "prefix_cost": "5.80",
                  "data_read_per_join": "345"
                },
                "used_columns": [
                  "dept_no",
                  "to_date"
                ],
                "attached_condition": "(`employees`.`dept_manager`.`to_date` is not null)"
              }
            }
          }
        }
      }
    ]
  }
}
```

This way few things could have been explain better.

[Sumanau Sareen](https://hashnode.com/@sumanau7)

[Nov 25, 2021](https://hashnode.com/posts/database-indexing-101-part-2/619f134ef015481b2669c71e/comment/619f2fddf015481b2669c9b9#reply-619f64c09829fb749bcbe46e)

Thanks for the feedback, I will accommodate that in my upcoming blogs.
