# Whats the best way to count the number of records in a database?

**URL:** https://community.fibery.io/t/whats-the-best-way-to-count-the-number-of-records-in-a-database/4374
**Category:** API & Programming
**Created:** [April 25, 2023, 8:58pm UTC](https://community.fibery.io/t/whats-the-best-way-to-count-the-number-of-records-in-a-database/4374 "2023-04-25T20:58:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![helloitse](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/helloitse/32/498_2.png) [@helloitse](https://community.fibery.io/u/helloitse)
#### Post date: [April 25, 2023, 8:58pm UTC](https://community.fibery.io/t/whats-the-best-way-to-count-the-number-of-records-in-a-database/4374/1 "2023-04-25T20:58:26Z")

</div>

Periodically, I sync a large database from Fibery to another platform. I do this in batches of 500 records.  
Right now, I send the same query that use to retrieve the record details in a batch of 500 with the q\no-limit parameter. Then store the length of the Body array that is returned and use that to determine the number of pages I need to retrieve.

```auto
{
    "command": "fibery.entity/query",
    "args": {
      "query": {
        "q/from": "Space/Database",
        "q/select": {
          "fibery/id": [
            "fibery/id"
          ]
        },
        "q/where": [
          "and",
          [
            "!=",
            [
              "Space/Database",
              "fibery/id"
            ],
            "$where1"
          ],
          [
            "q/not-contains",
            [
              "Space/Field"
            ],
            "$where2"
          ]
        ],
        "q/offset": 0,
        "q/limit": "q/no-limit"
      },
      "params": {
        "$where1": null,
        "$where2": "text"
      }
    }
  }

```

Is this the most efficient api call to get a count of how many records there are in a database?
