> 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/audience-and-activation/build-your-audiences/segment-reference/segment-types/query-segment.md).

# Query segment

The segment type computed from a query on your datamart, and the one type where persistence is a choice.

## What it is

A **Query segment** holds the users who satisfy a query on your datamart. It is the most common type, and the only one whose membership is recomputed on a schedule rather than filled by an external event.

Three tools produce a Query segment, and all three save the same object:

| Tool                                                                                                                                     | Who it is for                                                           |
| ---------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------- |
| [Standard Segment Builder](/audience-and-activation/build-your-audiences/segment-reference/segment-builders/standard-segment-builder.md) | Business users, working from pre-built audience features                |
| [Advanced Segment Builder](/audience-and-activation/build-your-audiences/segment-reference/segment-builders/advanced-segment-builder.md) | Users familiar with their schema, building AND / OR conditions visually |
| [Expert OTQL Builder](/audience-and-activation/build-your-audiences/segment-reference/segment-builders/expert-otql-builder.md)           | Schema and data experts, writing OTQL directly                          |

## What is specific to this type

* **Persistence is a choice.** Every other segment type is always persisted. On a Query segment you decide, and the decision has consequences - see [Counting is not persistence](/audience-and-activation/build-your-audiences/segment-reference.md#counting-is-not-persistence).
* **It has an evaluation period.** By default the segment is recalculated once a day. This is a maximum interval, not a guarantee of timing.
* **Default lifetime does not apply.** Users leave a Query segment when they stop matching the query, not on a timer.

See [Segment properties](/audience-and-activation/build-your-audiences/segment-reference.md#segment-properties) for all five advanced fields.

## Editing one

You edit a Query segment through the tool that created it.

{% stepper %}
{% step %}

### Open the segment

Go to **Audience > Segments** and click the segment, then click **Edit**.
{% endstep %}

{% step %}

### Edit the query

If the segment was built in the Advanced Segment Builder, click **Edit Query** to reach the builder, change your criteria, then click **Update**.

If the segment was written in OTQL - through the query tool or as a User Expert Query - edit the query in its dedicated zone.
{% endstep %}

{% step %}

### Save

Click **Save**. In the builder, `Update` only applies the change to the query - the segment itself is saved by the final **Save**, and a warning reminds you of that step.
{% endstep %}
{% endstepper %}

{% hint style="info" %}
After an edit, the segment must be computed again before its user count updates. Feeds attached to it adjust at that point: they upsert and delete users according to the newly computed segment, rather than resending the whole segment.
{% endhint %}

## 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>Compute your audience from stored data</strong></td><td>Building this type of segment, end to end.</td><td><a href="/audience-and-activation/build-your-audiences/target-your-audience-based-on-criteria/compute-your-audience-from-stored-data.md">Compute your audience from stored data</a></td></tr><tr><td><strong>Segment types</strong></td><td>The other eight types.</td><td><a href="/audience-and-activation/build-your-audiences/segment-reference/segment-types.md">Segment types</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/audience-and-activation/build-your-audiences/segment-reference/segment-types/query-segment.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.
