Questions about index with type(label)

Hi, I’m building a database using Dgraph. When I architect data relationship, I need types(or label) of data. I search many article about this, but the unclear parts are remain.

Here is my understanding.

When I use types, it is better to use a particular predicate for each type and use has function to search or filter this. This is because that indexing is unique so it can be too large if I use one predicate.

Here are my questions. Below query is came from docs.

  q(func: has(foo)) {
    pred @filter(bar) {

  1. To use @filter on pred, I need to index pred. Should I give different pred by types or can I use same pred?
    E.g. op1) use name as predicate of CITY type and COUNTRY type.
    op2) use city_name as predicate of CITY type and use country_name as predicate of the other.

  2. On above query, if I have other types and they have pred, how does dgraph work? - filter by bar on all index table? or filter by bar on result of has(foo)?

  3. If I use same predicates across all subject like create_datetime and use index, is it possible cause a performance issue or memory issue?

Thanks :slight_smile:

Has( ) don’t uses indexes. So you can use has with or without it.

No. Can’t see why it would happen - because this usage is normal. But obviously, if you have a giant dataset, you need more resources.


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