-
Notifications
You must be signed in to change notification settings - Fork 0
Annotation Reference
| Annotation | On | Arguments |
|---|---|---|
@timescale.hypertable |
model |
column (required), chunkInterval (default "7 days"); partitionColumn + partitions (optional) — a hash space dimension; chunkSkipping (optional) — secondary column(s) to enable chunk skipping on |
@timescale.retention |
model (also a hypertable) |
dropAfter (required) — drop chunks older than this interval |
@timescale.compression |
model (also a hypertable) |
after (required) — compress chunks older than this; segmentBy, orderBy (optional) — columnstore tuning (Prisma field names) |
@timescale.continuousAggregate |
view |
source (a hypertable or another cagg), bucket, timeColumn (required); refresh: { startOffset, endOffset, scheduleInterval }, materializedOnly (optional) |
@timescale.bucket |
view field | — (exactly one per aggregate) |
@timescale.groupBy |
view field | — |
@timescale.aggregate |
view field |
fn (avg|sum|min|max|count), column
|
See: Hypertables, Continuous aggregates, Retention & compression.
Intervals are "<amount> <unit>" where unit is any PostgreSQL interval input unit — microsecond(s), millisecond(s), second(s), minute(s), hour(s), day(s), week(s), month(s), year(s), decade(s), or centur(y|ies) — validated at compile time and runtime ("1 hour", "7 days", "2 years").
quarteris not an interval unit in PostgreSQL; combined forms like"1 year 2 months"aren't supported by this single-unit type.
Add partitionColumn + partitions to @timescale.hypertable for a hash space dimension (add_dimension(..., by_hash(column, partitions))) on top of the time dimension:
/// @timescale.hypertable(column: "time", chunkInterval: "1 day", partitionColumn: "deviceId", partitions: 4)
model SensorReading {
time DateTime
deviceId Int
@@id([deviceId, time]) // a partitioning column must be part of the table's PK / unique key
}partitionColumn takes a Prisma field name (mapped to its @map column); partitions is a positive integer. It's transparent to timeBucket queries and survives prisma migrate reset. More in Hypertables.
Add chunkSkipping (a Prisma field name, or several comma-separated) to @timescale.hypertable to record per-chunk min/max range stats on a secondary column so the planner can exclude non-matching compressed chunks. Remember to turn timescaledb.enable_chunk_skipping on at query time — see Hypertables → Chunk skipping for the full story and caveats.