# Count all edges

**URL:** <https://discuss.dgraph.io/t/count-all-edges/11140>\
**Category:** Dgraph\
**Tags:** kind:question\
**Created:** [October 27, 2020, 7:10am UTC](https://discuss.dgraph.io/t/count-all-edges/11140 "2020-10-27T07:10:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jokk33](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/jokk33/32/5092_2.png) [@jokk33](https://discuss.dgraph.io/u/jokk33)\
**Post date:** [October 27, 2020, 7:10am UTC](https://discuss.dgraph.io/t/count-all-edges/11140/1 "2020-10-27T07:10:01Z")

</div>

I am wondering is there any good way to count all edges.  
schema is simple:

```auto
node1: string @index(exact) .
node2: string @index(exact) .
node3: string @index(exact) .
rela1: [uid] @count .
rela2: [uid] @count .
rela3: [uid] @count .

```

Data:

```auto
# nodes
_:x1 <node1> "a1" .
_:x1 <node2> "b1" .
_:x1 <node3> "c1" .
_:x2 <node1> "a2" .
_:x2 <node2> "b2" .
_:x2 <node3> "c2" .
_:x3 <node1> "a3" .
_:x3 <node2> "b3" .
_:x3 <node3> "c3" .
...

# edges
_:x1 <rela1> _:x2 .
_:x1 <rela2> _:x2 .
_:x1 <rela3> _:x2 .
_:x2 <rela1> _:x1 .
_:x2 <rela2> _:x1 .
_:x2 <rela3> _:x1 .
_:x3 <rela1> _:x1 .
_:x3 <rela2> _:x1 .
...

```

I want to count all edges (including rela1, rela2, rela3)  
Below codes do work, but just for single edge, how can I calculate all edges, by using type function (avoiding “has” to save time)

```auto
{    
  var(func: has(rela1)) {
    c as count(rela1)
  }
	  Cul() {
   total: sum(val(c))
  }
}

```

---

<div class="post-metadata">

**Author:** ![rajas](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/rajas/32/4393_2.png) [@rajas](https://discuss.dgraph.io/u/rajas)\
**Post date:** [October 27, 2020, 12:30pm UTC](https://discuss.dgraph.io/t/count-all-edges/11140/2 "2020-10-27T12:30:24Z")

</div>

You may use some DQL query like this

```auto
{    
  var(func: type(/*Type of node*/)) {
    c as count(rela1)
    d as count(rela2)
    e as count(rela3)
    f as math(c+d+e)
  }
	  Cul() {
   total_edges: sum(val(f))
  }
}

```
