# How does type system work?

**URL:** <https://discuss.dgraph.io/t/how-does-type-system-work/17616>\
**Category:** Dgraph\
**Tags:** kind:question\
**Created:** [August 3, 2022, 6:51pm UTC](https://discuss.dgraph.io/t/how-does-type-system-work/17616 "2022-08-03T18:51:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![yasser-sobhy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/yasser-sobhy/32/9940_2.png) [@yasser-sobhy](https://discuss.dgraph.io/u/yasser-sobhy)\
**Post date:** [August 3, 2022, 6:51pm UTC](https://discuss.dgraph.io/t/how-does-type-system-work/17616/1 "2022-08-03T18:51:36Z")

</div>

Hi there, I am new to Dgraph and having hard time understanding how this type system works

## What I want to do

I want to query all nodes having a specific type

## What I did

I added one type to Dgraph, User, along with 25 predicates

```auto
type User {
    id
    name
    email
    phone
    login
    ...
}

id: int @index(int) .
name: string @index(fulltext) .
email: string @index(hash) .
phone: string @index(hash) .
login: string @index(hash) .
....

```

Then used Live Loader to load json data into dgraph, a sample row:

```auto
{
    "id": 1,
    "name": "Robbert",
    "email": "rdelacourt0@about.me",
    "phone": "429-267-5796",
    "login": "rcreggan0",
    ....
    "dgraph.type": "User"
}

```

Now, when I run the following query to query how many user nodes I have in the system:

```auto
{
  count_users(func: type(User)) {
    count(uid)
  }
}

```

I get

```auto
{
  "data": {
    "count_users": [
      {
        "count": 1133110
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 45326,
      "processing_ns": 2229090,
      "encoding_ns": 105251515,
      "total_ns": 107647656
    },
    "txn": {
      "start_ts": 1070210
    },
    "metrics": {
      "num_uids": {
        "_total": 0,
        "dgraph.type": 0
      }
    }
  }
}

```

But when I don’t query the node type I get much more bigger number

```auto
{
      nodeCount(func: has(<age>)) {
        nodeCount: count(uid)
      }
    }

```

Result

```auto
{
  "data": {
    "nodeCount": [
      {
        "nodeCount": 17604000
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 49660,
      "processing_ns": 54619211815,
      "encoding_ns": 1700891760,
      "assign_timestamp_ns": 851778,
      "total_ns": 56321128868
    },
    "txn": {
      "start_ts": 1070164
    },
    "metrics": {
      "num_uids": {
        "_total": 0,
        "age": 0
      }
    }
  }
}

```

Also this query’s metrics confuses me and I don’t know what they mean. I counld’t find anything that explains them

```auto
{
      nodeCount(func: has(<age>)) @filter(eq(dgraph.type, User)) {
        nodeCount: count(uid)
      }
    }

```

Result

```auto
{
  "data": {
    "nodeCount": [
      {
        "nodeCount": 1133110
      }
    ]
  },
  "extensions": {
    "server_latency": {
      "parsing_ns": 57466,
      "processing_ns": 51066224278,
      "encoding_ns": 131496865,
      "total_ns": 51197953773
    },
    "txn": {
      "start_ts": 1070181
    },
    "metrics": {
      "num_uids": {
        "_total": 17604000,
        "age": 0,
        "dgraph.type": 17604000
      }
    }
  }
}

```

So, my question is: which query is correct and why the numbers are lower when I query using node type?

Thanks

## Dgraph metadata

> **dgraph version**
>
> Dgraph version : v21.12.0  
> Dgraph codename : zion  
> Dgraph SHA-256 : 078c75df9fa1057447c8c8afc10ea57cb0a29dfb22f9e61d8c334882b4b4eb37  
> Commit SHA-1 : d62ed5f15  
> Commit timestamp : 2021-12-02 21:20:09 +0530  
> Branch : HEAD  
> Go version : go1.17.3  
> jemalloc enabled : true

---

<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:** [August 3, 2022, 9:16pm UTC](https://discuss.dgraph.io/t/how-does-type-system-work/17616/2 "2022-08-03T21:16:43Z")

</div>

Hey @yasser-sobhy,

Welcome to dgraph! Two questions for you:

1. What version dgraph are you trying this on?
2. How many `User` records did you import?

Also, regarding `extensions`, have a look here: [https://dgraph.io/docs/graphql/api/requests/#extensions-field](https://dgraph.io/docs/graphql/api/requests/#extensions-field)
