> For the complete documentation index, see [llms.txt](https://docs.mediarithmics.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mediarithmics.io/setup-and-monitor/operate-and-monitor/query-your-datamart.md).

# Query your datamart

Three query languages, three jobs - and how to pick between them.

## Your goal

Get an answer out of the datamart, with the right tool for the question you are asking.

## Expected outcome

Queries that return what you expect, fast enough for the context they run in.

## Three ways, three jobs

The datamart exposes three query languages, each designed for a different job.

| Language    | Use it to                                                                                  | Typical context                                                                                                                                             |
| ----------- | ------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **GraphQL** | Query **the local graph of a single user**, in real time                                   | Real-time personalisation, a lookup on one person                                                                                                           |
| **OTQL**    | Query **the whole object graph in a couple of seconds**, even with billions of data points | Audience segmentation, data exploration, volumetry                                                                                                          |
| **SQL**     | Run **analysis of your behavioural data**                                                  | Activities analytics - see [Data cube (Activities Analytics)](/setup-and-monitor/operate-and-monitor/query-your-datamart/data-cube-activities-analytics.md) |

{% hint style="info" %}
OTQL is an **extension to GraphQL**. It is based on the same schema and adds features for querying a graph of millions or billions of objects. If you know one, the other is not far.
{% endhint %}

Which fields you can query, and which you can filter on, is entirely determined by your [schema](/setup-and-monitor/collect-and-manage-your-data/design-your-data-model-and-schema/schema-definition.md). A field without `@TreeIndex` can be selected but not used in a `WHERE` clause.

## Choose by the question

| The question                                         | The tool                                                                                                                                                                                      |
| ---------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| "What do we know about **this** user, right now?"    | [GraphQL queries](/setup-and-monitor/operate-and-monitor/query-your-datamart/graphql-queries.md) - a single request returns profile, activities, segments, and identifiers for one UserPoint. |
| "How many users match these criteria?"               | [OTQL](/setup-and-monitor/operate-and-monitor/query-your-datamart/otql.md)                                                                                                                    |
| "Which users match, so I can put them in a segment?" | [OTQL](/setup-and-monitor/operate-and-monitor/query-your-datamart/otql.md) - segment definitions are OTQL.                                                                                    |
| "How did conversions evolve by category last month?" | [Data cube (Activities Analytics)](/setup-and-monitor/operate-and-monitor/query-your-datamart/data-cube-activities-analytics.md)                                                              |
| "I want to explore, interactively"                   | [Query Tool](/setup-and-monitor/operate-and-monitor/query-your-datamart/query-tool.md)                                                                                                        |
| "I want this to run from my code"                    | [Query API](/setup-and-monitor/operate-and-monitor/query-your-datamart/query-api.md)                                                                                                          |
| "I need the answer as a file"                        | [Export](/setup-and-monitor/collect-and-manage-your-data/export-your-data/export.md) - built on a saved OTQL query.                                                                           |

## In this section

<table data-view="cards" data-search="false"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>OTQL</strong></td><td>The language for querying the whole graph.</td><td><a href="/setup-and-monitor/operate-and-monitor/query-your-datamart/otql.md">OTQL</a></td></tr><tr><td><strong>GraphQL queries</strong></td><td>Everything about one user, in one request.</td><td><a href="/setup-and-monitor/operate-and-monitor/query-your-datamart/graphql-queries.md">GraphQL queries</a></td></tr><tr><td><strong>Query API</strong></td><td>Saving, checking, and executing queries programmatically.</td><td><a href="/setup-and-monitor/operate-and-monitor/query-your-datamart/query-api.md">Query API</a></td></tr><tr><td><strong>Query Tool</strong></td><td>Exploring interactively in Data Studio.</td><td><a href="/setup-and-monitor/operate-and-monitor/query-your-datamart/query-tool.md">Query Tool</a></td></tr><tr><td><strong>Data cube (Activities Analytics)</strong></td><td>Analysing behavioural data.</td><td><a href="/setup-and-monitor/operate-and-monitor/query-your-datamart/data-cube-activities-analytics.md">Data cube (Activities Analytics)</a></td></tr><tr><td><strong>Retrieve user data using GraphQL API</strong></td><td>A worked walkthrough for one user.</td><td><a href="/setup-and-monitor/operate-and-monitor/query-your-datamart/retrieve-user-data-using-graphql-api.md">Retrieve user data using GraphQL API</a></td></tr></tbody></table>

## Related pages

<table data-view="cards" data-search="false"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Schema definition</strong></td><td>What determines what you can query.</td><td><a href="/setup-and-monitor/collect-and-manage-your-data/design-your-data-model-and-schema/schema-definition.md">Schema definition</a></td></tr><tr><td><strong>Explore a user profile</strong></td><td>Looking one user up in the interface.</td><td><a href="/setup-and-monitor/operate-and-monitor/explore-a-user-profile.md">Explore a user profile</a></td></tr><tr><td><strong>Create a custom dashboard</strong></td><td>Turning queries into something your teams read.</td><td><a href="/setup-and-monitor/operate-and-monitor/create-a-custom-dashboard.md">Create a custom dashboard</a></td></tr></tbody></table>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mediarithmics.io/setup-and-monitor/operate-and-monitor/query-your-datamart.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
