Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarify DEDUP sorting behaviour #87

Merged
merged 3 commits into from
Nov 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions documentation/concept/deduplication.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,29 @@ precisely, deduplicating the data based on the device ID can be expensive.
However, in cases where CPU metrics are sent at random and typically have unique
timestamps, the cost of deduplication is negligible.

:::note

The ordering of how rows with duplicate timestamps are written on-disk differs when deduplication is enabled.
nwoolmer marked this conversation as resolved.
Show resolved Hide resolved

- Without deduplication:
- the insertion order of each row will be preserved for rows with the same timestamp
- With deduplication:
- the rows will be stored in order sorted by the `DEDUP UPSERT` keys, with the same timestamp

For example:

```questdb-sql
DEDUP UPSERT keys(timestamp, symbol, price)

-- will sorted like this on-disk:
nwoolmer marked this conversation as resolved.
Show resolved Hide resolved

ORDER BY timestamp, symbol, price
```

This is the natural order of data returned in plain queries, without any grouping, filtering or ordering.
nwoolmer marked this conversation as resolved.
Show resolved Hide resolved

:::

## Configuration

Create a WAL-enabled table with deduplication using
Expand Down