---
title: "Sessions counts (fast)"
description: "Get session count summaries with sessions_counts_fast, a GraphQL function backed by materialized views for fast queries on large datasets."
---

# Sessions counts (fast)

> Get session count summaries with sessions_counts_fast, a GraphQL function backed by materialized views for fast queries on large datasets.

## Overview

The `sessions_counts_fast` function provides a performance-optimized way to retrieve session counts. This fast variant uses materialized views for improved query performance on large datasets. Use this endpoint to:

- Get quick session count summaries for dashboards
- Build high-performance reporting interfaces
- Handle large-scale analytics with reduced query latency

## Quick start

```graphql
query SessionsCountsFast(
  $accountId: uuid
  $deskIds: _uuid
  $brainIds: _uuid
  $startDate: timestamp
  $endDate: timestamp
  $isTest: Boolean
) {
  rows: sessions_counts_fast(
    args: {
      account_id: $accountId
      desk_ids: $deskIds
      brain_parent_ids: $brainIds
      start_time: $startDate
      end_time: $endDate
      is_test: $isTest
    }
  ) {
    counts
  }
}
```

**Variables:**

```json
{
  "accountId": "991c12a1-cc58-4377-8e37-f72259e9dac1",
  "startDate": "2024-01-08",
  "endDate": "2024-01-17"
}
```

## Parameters

| Parameter    | Type        | Description                       |
| ------------ | ----------- | --------------------------------- |
| `accountId`  | `uuid`      | Account identifier                |
| `deskIds`    | `_uuid`     | Filter by desk IDs                |
| `brainIds`   | `_uuid`     | Filter by AI agent IDs            |
| `startDate`  | `timestamp` | Start date (format: `yyyy-mm-dd`) |
| `endDate`    | `timestamp` | End date (format: `yyyy-mm-dd`)   |
| `isTest`     | `Boolean`   | Exclude test sessions             |

## Response fields

| Field    | Type  | Description               |
| -------- | ----- | ------------------------- |
| `counts` | `Int` | Total number of sessions  |

## Common use cases

## Try it

<GraphiQLPlayground
  query={`query SessionsCountsFast(
  \$accountId: uuid
  \$deskIds: _uuid
  \$brainIds: _uuid
  \$startDate: timestamp
  \$endDate: timestamp
  \$isTest: Boolean
) {
  rows: sessions_counts_fast(
    args: {
      account_id: \$accountId
      desk_ids: \$deskIds
      brain_parent_ids: \$brainIds
      start_time: \$startDate
      end_time: \$endDate
      is_test: \$isTest
    }
  ) {
    counts
  }
}`}
  variables={`{
  "accountId": "991c12a1-cc58-4377-8e37-f72259e9dac1",
  "startDate": "2024-01-08",
  "endDate": "2024-01-17"
}`}
  endpoint="https://logs.moveo.ai/v1/graphql"
/>

**Account totals**

Get total session count for an account:

```json
{
  "accountId": "991c12a1-cc58-4377-8e37-f72259e9dac1",
  "startDate": "2024-01-08",
  "endDate": "2024-01-17"
}
```

**Multiple AI agents**

Filter by multiple AI agents:

```json
{
  "accountId": "991c12a1-cc58-4377-8e37-f72259e9dac1",
  "brainIds": "{a2wv9283-9b53-4d7b-b77d-2650f3a1a99c, 99xx33p9-dfab-44e5-9303-9b2bf13f1c94}",
  "startDate": "2024-01-08",
  "endDate": "2024-01-17"
}
```

**Exclude test sessions**

Get production session counts only:

```json
{
  "accountId": "991c12a1-cc58-4377-8e37-f72259e9dac1",
  "isTest": false,
  "startDate": "2024-01-08",
  "endDate": "2024-01-17"
}
```

## Example response

```json
{
  "data": {
    "rows": [
      {
        "counts": 15000
      }
    ]
  }
}
```
