# Upsert and Dedup

Upsert and dedup are for tables that ingest repeated keys. Use them when the current value matters more than the raw event history, or when duplicate events should not fan out into duplicate query results.

## Choose the right behavior

Use upsert when newer rows should replace older rows for the same primary key.

Use dedup when repeated records should be filtered out and only the first or unique representation should remain.

## Operational notes

These patterns need a careful schema, a stable primary key, and ingestion flow that understands the table-level metadata Pinot uses to keep the result consistent.

The strongest detail still lives in the original docs under [Upsert and Dedup](/build-with-pinot/ingestion/upsert-dedup.md).

## What this page covered

This page covered the difference between upsert and dedup and when each is the better fit.

## Next step

Read [Formats and Filesystems](/build-with-pinot/ingestion/formats-filesystems.md) to decide how Pinot should read source data and store generated segments.

## Related pages

* [Ingestion](/build-with-pinot/ingestion.md)
* [Batch Ingestion](/build-with-pinot/ingestion/batch-ingestion.md)
* [Stream Ingestion](/build-with-pinot/ingestion/stream-ingestion.md)
* [Formats and Filesystems](/build-with-pinot/ingestion/formats-filesystems.md)
* [Original Upsert and Dedup Docs](/build-with-pinot/ingestion/upsert-dedup.md)


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pinot.apache.org/build-with-pinot/ingestion/upsert-dedup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
