# Is hash+exact indexing useful?

**URL:** <https://discuss.dgraph.io/t/is-hash-exact-indexing-useful/17843>\
**Category:** Dgraph\
**Tags:** kind:question, dgraph, area:indexes\
**Created:** [October 7, 2022, 12:41am UTC](https://discuss.dgraph.io/t/is-hash-exact-indexing-useful/17843 "2022-10-07T00:41:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RivenAster](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/rivenaster/32/10065_2.png) [@RivenAster](https://discuss.dgraph.io/u/RivenAster)\
**Post date:** [October 7, 2022, 12:41am UTC](https://discuss.dgraph.io/t/is-hash-exact-indexing-useful/17843/1 "2022-10-07T00:41:01Z")

</div>

## What I want to do

Optimize performance of both equality checking and sorting.

## What I did

Indexed the same string predicate with both `hash` and `exact`.

## Question

String predicates offer several indexes. [The docs](https://dgraph.io/docs/query-language/schema/#string-indices) say:

> The most performant index for `eq` is `hash`.

About the `exact` index the docs say:

> Allows faster sorting.

Based on this I’ve been using `hash` and `exact` where I want fast sorting + optimal equality checking.

```auto
type Event {
  Event.type
}
Event.type: string @index(hash, exact) .

```

The 2 indexes seem to have different characteristics. If I pull a list of nodes for a table, I’d like to have them sort efficiently, especially for a long list where I’ll have to pull many pages (`exact`). If I’m doing many queries that check a precise string, I’d like them to be as fast as possible (`hash`).

Ratel complains about this, saying it’s a bad pattern. It won’t even let you save with both of them:

> ‘exact’ and ‘hash’ index types shouldn’t be used together

Is this right? I was surprised to see a blanket prohibition. Does it make sense to use them together? Will `hash` even be used for equality checking if there’s also an `exact` index?
