# How to check the DQL execution plan

**URL:** https://discuss.dgraph.io/t/how-to-check-the-dql-execution-plan/19774
**Category:** Dgraph
**Tags:** debug
**Created:** [February 19, 2025, 1:55am UTC](https://discuss.dgraph.io/t/how-to-check-the-dql-execution-plan/19774 "2025-02-19T01:55:38Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![leo\_berglin](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/leo_berglin/32/11773_2.png) [@leo\_berglin](https://discuss.dgraph.io/u/leo_berglin)
#### Post date: [February 19, 2025, 1:55am UTC](https://discuss.dgraph.io/t/how-to-check-the-dql-execution-plan/19774/1 "2025-02-19T01:55:38Z")

</div>

I used the `explain` keyword in Dgraph 24.0.5 but got the error “Invalid operation type: explain.”

```auto
explain {
	getUsers(func: has(name)) {
    name
    follows {
      name
    }
  }
}

```

I would appreciate it if you could let me know how to get the execution plan of a query, similar to MySQL.

---

<div class="post-metadata">

### Author: ![harshil\_goel](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/harshil_goel/32/3737_2.png) [@harshil\_goel](https://discuss.dgraph.io/u/harshil_goel)
#### Post date: [February 19, 2025, 6:16am UTC](https://discuss.dgraph.io/t/how-to-check-the-dql-execution-plan/19774/2 "2025-02-19T06:16:51Z")

</div>

We dont’ have any query plan as of right now. Since the query structure is a graph, we really don’t change much like in mysql. We have to traverse the graph in the manner the query specifies.

---

<div class="post-metadata">

### Author: ![leo\_berglin](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/leo_berglin/32/11773_2.png) [@leo\_berglin](https://discuss.dgraph.io/u/leo_berglin)
#### Post date: [February 19, 2025, 6:33am UTC](https://discuss.dgraph.io/t/how-to-check-the-dql-execution-plan/19774/3 "2025-02-19T06:33:37Z")

</div>

How do I check if the DQL I created is optimized?  
I would really appreciate it if you could tell me how to check how the query is executed.

---

<div class="post-metadata">

### Author: ![harshil\_goel](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/harshil_goel/32/3737_2.png) [@harshil\_goel](https://discuss.dgraph.io/u/harshil_goel)
#### Post date: [February 19, 2025, 6:36am UTC](https://discuss.dgraph.io/t/how-to-check-the-dql-execution-plan/19774/4 "2025-02-19T06:36:44Z")

</div>

There’s no way to check if the DQL is optimized or not. If you think the performance is not upto the mark, then we can take a look and help you see how to optimize it. The query will get executed just as you input it. You could look at the traces generated by Dgraph to see what the query did.

> [@Can dgraph support execute plan?](https://discuss.hypermode.com/t/can-dgraph-support-execute-plan/10818):
>
> Just like explain in SQL or other database system. Can dgraph support query plan to show the cost of io or cpu of each function? A query may be like this: query { q(func: has(name)){ uid } } The grammar I expect may like this: explain { q(func: has(name)){ uid } } Just replace the keyword query to explain.

---

<div class="post-metadata">

### Author: ![matthewmcneely](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/matthewmcneely/32/4774_2.png) [@matthewmcneely](https://discuss.dgraph.io/u/matthewmcneely)
#### Post date: [February 19, 2025, 4:32pm UTC](https://discuss.dgraph.io/t/how-to-check-the-dql-execution-plan/19774/5 "2025-02-19T16:32:23Z")

</div>

@leo_berglin Also have a look at the `extensions` field in the results. Looking at the UID count your query produced is the first step at optimizing queries. Then, I recommend you search this forum for “optimize” and you’ll uncover all sorts of threads on the subject.

---

<div class="post-metadata">

### Author: ![leo\_berglin](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/leo_berglin/32/11773_2.png) [@leo\_berglin](https://discuss.dgraph.io/u/leo_berglin)
#### Post date: [February 20, 2025, 2:40am UTC](https://discuss.dgraph.io/t/how-to-check-the-dql-execution-plan/19774/6 "2025-02-20T02:40:19Z")

</div>

@matthewmcneely thanks for your help
