# Performance question: "x is\_type boolean" or "x \<type\> value"

**URL:** <https://discuss.dgraph.io/t/performance-question-x-is-type-boolean-or-x-type-value/1840>\
**Category:** Users\
**Created:** [October 8, 2017, 11:39am UTC](https://discuss.dgraph.io/t/performance-question-x-is-type-boolean-or-x-type-value/1840 "2017-10-08T11:39:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![lazharichir](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/lazharichir/32/1047_2.png) [@lazharichir](https://discuss.dgraph.io/u/lazharichir)\
**Post date:** [October 8, 2017, 11:39am UTC](https://discuss.dgraph.io/t/performance-question-x-is-type-boolean-or-x-type-value/1840/1 "2017-10-08T11:39:53Z")

</div>

Just wondering what would be the best practice to typify the nodes in my dgraph database. Nodes can either be ‘topics’ or ‘phrases’ (might have more in the future.) There will be over 100 millions of nodes in production.

What would be the best approach, using an indexed predicate that defines takes a string value holding the node type:

```auto
_:0 <xid> "abc" .
_:0 <type> "topic" .
_:1 <xid> "xyz" .
_:1 <type> "phrase" .

```

Or, using an indexed boolean predicate labeled for each type:

```auto
_:0 <xid> "abc" .
_:0 <is_topic> true .
_:1 <xid> "xyz" .
_:1 <is_term> true .

```

What is the most suitable, performant and scalable solution for those who do have an idea?

---

<div class="post-metadata">

**Author:** ![pawan](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pawan/32/1946_2.png) [@pawan](https://discuss.dgraph.io/u/pawan)\
**Post date:** [October 8, 2017, 10:44pm UTC](https://discuss.dgraph.io/t/performance-question-x-is-type-boolean-or-x-type-value/1840/2 "2017-10-08T22:44:31Z")

</div>

Hey @lazharichir

That’s a good question and we have been recommending the first method i.e. defining a string `type` edge. The advantage is that you can just use the same predicate in your queries while checking for type instead of checking for a different predicate each time.

Both should be equally performant as they would generate equal sized index posting lists.

---

<div class="post-metadata">

**Author:** ![pmualaba](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/pmualaba/32/1035_2.png) [@pmualaba](https://discuss.dgraph.io/u/pmualaba)\
**Post date:** [October 14, 2017, 7:27pm UTC](https://discuss.dgraph.io/t/performance-question-x-is-type-boolean-or-x-type-value/1840/3 "2017-10-14T19:27:53Z")

</div>

Will the second method not be better to equaly distribute edges over multiple machines in a dgraph cluster? With the first approach you will always have a type predicate for every node, which will probably also increase the index size / slowing down lookup performance of that “large” type predicate index?

---

<div class="post-metadata">

**Author:** ![peter](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/peter/32/574_2.png) [@peter](https://discuss.dgraph.io/u/peter)\
**Post date:** [October 15, 2017, 10:30pm UTC](https://discuss.dgraph.io/t/performance-question-x-is-type-boolean-or-x-type-value/1840/4 "2017-10-15T22:30:50Z")

</div>

That’s a good point. The second approach replaces one large predicate with many smaller predicates, which scales better when using a larger cluster.

---

<div class="post-metadata">

**Author:** ![mrjn](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/mrjn/32/775_2.png) [@mrjn](https://discuss.dgraph.io/u/mrjn)\
**Post date:** [October 17, 2017, 12:47am UTC](https://discuss.dgraph.io/t/performance-question-x-is-type-boolean-or-x-type-value/1840/5 "2017-10-17T00:47:12Z")

</div>

Agreed. The second one is better. The first approach causes issues for us, because if you index on `type` edge, then it generates huge posting lists for us internally (topic → all nodes of type topic, phrase → all nodes of type phrase), which slows down everything.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex007/uploads/dgraph/original/2X/2/2b38fdece2abe5814f2e51bee69d1e67fc304b0a.png) [@system](https://discuss.dgraph.io/u/system)\
**Post date:** [November 16, 2017, 12:47am UTC](https://discuss.dgraph.io/t/performance-question-x-is-type-boolean-or-x-type-value/1840/6 "2017-11-16T00:47:13Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
