setup-timescaledb-hypertables_skill

This skill helps you design TimescaleDB hypertables with optimal partitioning, compression, retention, and continuous aggregates to improve time-series
  • Python

1.5k

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill timescale/pg-aiguide --skill setup-timescaledb-hypertables

  • SKILL.md17.6 KB

Overview

This skill provides step-by-step guidance for designing TimescaleDB hypertables and related objects: partitioning, segment_by and order_by selection, chunk interval tuning, sparse indexes, compression, retention policies, continuous aggregates, and real-time aggregation. It focuses on insert-heavy, append-only patterns and gives concrete SQL patterns and configuration advice to maximize storage efficiency and query performance.

How this skill works

The skill inspects typical time-series and append-only schemas and walks through creating hypertables with appropriate partition (time) and segment_by columns, setting order_by for natural progression, and configuring sparse indexes for compressed data. It then covers chunk time interval sizing, compression policies, retention rules, continuous aggregate definitions and refresh policies, real-time aggregation toggles, and compressing/retaining aggregates.

When to use it

  • Designing new time-series or event-log tables with heavy inserts and rare updates
  • Optimizing schemas for metrics, IoT telemetry, transaction logs, or audit trails
  • Setting up compression and sparse indexes to reduce storage and speed queries on compressed data
  • Creating continuous aggregates for dashboarding and long-term reporting
  • Tuning chunk interval and retention for predictable memory and storage behavior

Best practices

  • Always use a time-based partition column (timestamp/timestamptz/date) or a sequential integer for partitioning
  • Prefer a single segment_by column with >100 rows per value per chunk; if density is low, prepend that column to order_by instead
  • Use order_by = 'timestamp DESC' (or sequence DESC) to create natural progression for compression
  • Enable columnstore compression by default for insert-heavy workloads unless using incompatible types (e.g., pgvector)
  • Only create indexes and primary keys you will use; include the partition column in any PK/unique constraint
  • Match continuous aggregate start_offset to raw-table retention or comment out both if retention is unknown

Example use cases

  • IoT telemetry: device_id as segment_by, timestamp DESC order_by, minmax sparse indexes on temperature and pressure
  • High-frequency metrics: time_bucket hourly continuous aggregate for dashboards and daily aggregate for reports
  • Event logs: created_at partition, session_id in order_by when user_id density is low, retention policy for raw logs
  • Financial ticks: symbol as segment_by, timestamp DESC, small chunk interval (minutes to hours) for high-volume symbols
  • Append-only analytics: compress aggregates and set longer retention for aggregates than raw data

FAQ

Disable columnstore when the table contains incompatible types (e.g., vector types) or when you need frequent per-row updates that make compression counterproductive.

How do I choose chunk time interval?

Base it on ingestion volume: high-frequency use 1 hour–1 day, medium 1 day–1 week, low 1 week–1 month. Verify recent chunk indexes fit within ~25% of RAM.

What if segment_by values are low-density?

If <100 rows per value per chunk, avoid using that column as segment_by; instead prepend it to order_by to keep similar values adjacent for compression.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational