Skip to content

Commit c403ad4

Browse files
authored
docs: recommend designated timestamps as essential, not optional (#291)
1 parent b5d6fe7 commit c403ad4

File tree

1 file changed

+80
-32
lines changed

1 file changed

+80
-32
lines changed

documentation/concept/designated-timestamp.md

Lines changed: 80 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,104 @@
22
title: Designated timestamp
33
sidebar_label: Designated timestamp
44
description:
5-
How designated timestamps are implemented and why it is an important
6-
functionality for time series.
5+
Why every QuestDB table should have a designated timestamp and how to set one.
76
---
87

9-
QuestDB offers the option to elect a column as a _designated timestamp_. This
10-
allows you to specify which column the tables will be indexed by in order to
11-
leverage time-oriented language features and high-performance functionalities.
8+
Every table in QuestDB should have a designated timestamp. This column defines
9+
the time axis for your data and unlocks QuestDB's core time-series capabilities
10+
including partitioning, time-series joins, and optimized interval scans.
1211

13-
A designated timestamp is elected by using the
14-
[`timestamp(columnName)`](/docs/reference/function/timestamp/) function:
12+
Without a designated timestamp, a table behaves like a generic append-only
13+
store - you lose partitioning, efficient time-range queries, and most
14+
time-series SQL features.
1515

16-
- during a [CREATE TABLE](/docs/reference/sql/create-table/#designated-timestamp) operation
17-
- during a [SELECT](/docs/reference/sql/select/#timestamp) operation
18-
(`dynamic timestamp`)
19-
- when ingesting data via InfluxDB Line Protocol, for tables that do not already
20-
exist in QuestDB, partitions are applied automatically by day by default with
21-
a `timestamp` column
16+
## Why it matters
17+
18+
The designated timestamp is not just metadata - it determines how QuestDB
19+
physically organizes and queries your data. These features require it:
20+
21+
- [Partitioning](/docs/concept/partitions/)
22+
- [Time-series joins](/docs/reference/sql/join/) (ASOF, LT, SPLICE)
23+
- [Interval scan](/docs/concept/interval-scan/) optimization
24+
- [SAMPLE BY](/docs/reference/sql/sample-by/) queries
25+
- [LATEST ON](/docs/reference/sql/latest-on/) optimization
26+
- [TTL](/docs/concept/ttl/)
27+
- [Deduplication](/docs/concept/deduplication/)
28+
- [Replication](/docs/operations/replication/)
29+
30+
If your data has a time dimension - and for time-series workloads it always
31+
does - define a designated timestamp.
2232

2333
:::note
2434

25-
- There are two timestamp resolutions available in QuestDB: microseconds and nanoseconds. See
26-
[Timestamps in QuestDB](/docs/guides/working-with-timestamps-timezones/#timestamps-in-questdb)
27-
for more details.
35+
Static lookup or reference tables with no time dimension are the exception.
36+
These can be created without a designated timestamp.
2837

2938
:::
3039

40+
## How to set it
41+
42+
Use the [`timestamp(columnName)`](/docs/reference/function/timestamp/) function
43+
at table creation:
44+
45+
```questdb-sql
46+
CREATE TABLE readings (
47+
ts TIMESTAMP,
48+
sensor_id SYMBOL,
49+
value DOUBLE
50+
) TIMESTAMP(ts) PARTITION BY DAY;
51+
```
52+
53+
If you have multiple timestamp columns, designate the one you'll filter and
54+
aggregate by most often.
55+
56+
Other ways to set a designated timestamp:
57+
58+
- On query results: see [SELECT](/docs/reference/sql/select/#timestamp)
59+
(`dynamic timestamp`)
60+
- Via InfluxDB Line Protocol: tables created automatically include a `timestamp`
61+
column as the designated timestamp, partitioned by day by default
62+
63+
For full CREATE TABLE syntax, see the
64+
[reference documentation](/docs/reference/sql/create-table/#designated-timestamp).
65+
3166
## Properties
3267

3368
- Only a column of type `timestamp` or `timestamp_ns` can be elected as a designated timestamp.
3469
- Only one column can be elected for a given table.
3570

36-
## Checking the designated timestamp settings
71+
:::note
72+
73+
There are two timestamp resolutions available: microseconds and nanoseconds. See
74+
[Timestamps in QuestDB](/docs/guides/working-with-timestamps-timezones/#timestamps-in-questdb)
75+
for details.
76+
77+
:::
78+
79+
## Checking designated timestamp settings
80+
81+
The [meta functions](/docs/reference/function/meta/) `tables()` and
82+
`table_columns()` show the designated timestamp settings for a table.
83+
84+
## FAQ
85+
86+
**What if my data arrives out of order?**
87+
88+
QuestDB handles out-of-order data automatically during ingestion. No special
89+
configuration is required.
3790

38-
The [meta functions](/docs/reference/function/meta/), `tables()` and
39-
`table_columns()`, are designed to show the designated timestamp settings of the
40-
selected table.
91+
**Can I change the designated timestamp later?**
4192

42-
## Advantages of electing a designated timestamp
93+
No. The designated timestamp is set at table creation and cannot be changed.
94+
To use a different column, create a new table and migrate your data.
4395

44-
Electing a designated timestamp allows you to:
96+
**Can I add a designated timestamp to an existing table?**
4597

46-
- Partition tables by time range. For more information, see the
47-
[partitions reference](/docs/concept/partitions/).
48-
- Use time series joins such as `ASOF JOIN`. For more information, see the
49-
[ASOF JOIN reference](/docs/reference/sql/asof-join/) or the more general
50-
[JOIN reference](/docs/reference/sql/join/).
51-
- Optimize queries with [Interval scan](/docs/concept/interval-scan)
98+
No. You must define the designated timestamp when creating the table. If you
99+
have an existing table without one, create a new table with the designated
100+
timestamp and use `INSERT INTO ... SELECT` to migrate your data.
52101

53-
## Out-of-order policy
102+
**Can the designated timestamp contain NULL values?**
54103

55-
As of version 6.0.0, QuestDB supports the ingestion of records that are
56-
out-of-order (O3) by time. QuestDB detects and adjusts data ingestion for O3
57-
data automatically and no manual configuration is required.
104+
No. The designated timestamp column cannot contain NULL values. Every row must
105+
have a valid timestamp.

0 commit comments

Comments
 (0)