design-postgis-tables
Comprehensive PostGIS spatial table design reference covering geometry types, coordinate systems, spatial indexing, and…
Use this skill when creating database schemas or tables for Timescale, TimescaleDB, TigerData, or Tiger Cloud, especially for time-series, IoT, metrics, events, or log data. Use this to improve the performance of any insert-heavy table. **Trigger when user asks to:** - Create or
Claude Code
$ npx -y skills add timescale/pg-aiguide --skill setup-timescaledb-hypertables --agent claude-code
Codex
$ npx skills add timescale/pg-aiguide --skill setup-timescaledb-hypertables -a codex -y
Cursor
$ npx skills add timescale/pg-aiguide --skill setup-timescaledb-hypertables -a cursor -y
Gemini CLI
$ npx skills add timescale/pg-aiguide --skill setup-timescaledb-hypertables -a gemini-cli -y
GitHub Copilot
$ npx skills add timescale/pg-aiguide --skill setup-timescaledb-hypertables -a github-copilot -y
OpenCode
$ npx skills add timescale/pg-aiguide --skill setup-timescaledb-hypertables -a opencode -y
Windsurf
$ npx skills add timescale/pg-aiguide --skill setup-timescaledb-hypertables -a windsurf -y
name: setup-timescaledb-hypertables description: | Use this skill when creating database schemas or tables for Timescale, TimescaleDB, TigerData, or Tiger Cloud, especially for time-series, IoT, metrics, events, or log data. Use this to improve the performance of any insert-heavy table. **Trigger when user asks to:** - Create or design SQL schemas/tables AND Timescale/TimescaleDB/TigerData/Tiger Cloud is available - Set up hypertables, compression, retention policies, or continuous aggregates - Configure partition columns, segment_by, order_by, or chunk intervals - Optimize time-series database performance or storage - Create tables for sensors, metrics, telemetry, events, or transaction logs **Keywords:** CREATE TABLE, hypertable, Timescale, TimescaleDB, time-series, IoT, metrics, sensor data, compression policy, continuous aggregates, columnstore, retention policy, chunk interval, segment_by, order_by Step-by-step instructions for hypertable creation, column selection, compression policies, retention, continuous aggregates, and indexes. license: Apache-2.0 compatibility: Requires PostgreSQL 15+ with TimescaleDB metadata: author: tigerdata
Instructions for insert-heavy data patterns where data is inserted but rarely changed:
CREATE TABLE your_table_name (
timestamp TIMESTAMPTZ NOT NULL,
entity_id TEXT NOT NULL, -- device_id, user_id, symbol, etc.
category TEXT, -- sensor_type, event_type, asset_class, etc.
value_1 DOUBLE PRECISION, -- price, temperature, latency, etc.
value_2 DOUBLE PRECISION, -- volume, humidity, throughput, etc.
value_3 INTEGER, -- count, status, level, etc.
metadata JSONB -- flexible additional data
) WITH (
tsdb.hypertable,
tsdb.partition_column='timestamp',
tsdb.enable_columnstore=true, -- Disable if table has vector columns
tsdb.segmentby='entity_id', -- See selection guide below
tsdb.orderby='timestamp DESC', -- See selection guide below
tsdb.sparse_index='minmax(value_1),minmax(value_2),minmax(value_3)' -- see selection guide below
);Must be time-based (TIMESTAMP/TIMESTAMPTZ/DATE) or integer (INT/BIGINT) with good temporal/sequential distribution.
**Common patterns:**
**Less ideal:** `ingested_at` (when data entered system - use only if it's your primary query dimension) **Avoid:** `updated_at` (breaks time ordering unless it's primary query dimension)
**PREFER SINGLE COLUMN** - multi-column rarely optimal. Multi-column can only work for highly correlated columns (e.g., metric_name + metric_type) with sufficient row density.
**Requirements:**
**Examples:**
**Row density guidelines:**
**Query pattern drives choice:**
SELECT * FROM table WHERE entity_id = 'X' AND timestamp > ... -- ↳ segment_by: entity_id (if >100 rows per chunk)
**Avoid:** timestamps, unique IDs, low-density columns (<100 rows/value/chunk), columns rarely used in filtering
Creates natural time-series progression when combined with segment_by for optimal compression.
**Most common:** `timestamp DESC`
**Examples:**
**Alternative patterns:**
**Low-density column handling:** If a column has <100 rows per chunk (too low for segment_by), prepend it to order_by:
**Good test:** ordering created by `(segment_by_column, order_by_column)` should form a natural time-series progression. Values close to each other in the progression should be similar.
**Avoid in order_by:** random columns, columns with high variance between adjacent rows, columns unrelated to segment_by
**Sparse indexes** enable query filtering on compressed data without decompress
AI-optimized PostgreSQL expertise for coding assistants pg-aiguide helps AI coding tools write dramatically better PostgreSQL code.
Comprehensive PostGIS spatial table design reference covering geometry types, coordinate systems, spatial indexing, and…
Use this skill for general PostgreSQL table design. **Trigger when user asks to:** - Design PostgreSQL tables, schemas, or data…
Use this skill to analyze an existing PostgreSQL database and identify which tables should be converted to Timescale/TimescaleDB…
Use this skill to migrate identified PostgreSQL tables to Timescale/TimescaleDB hypertables with optimal configuration and…
Use this skill for setting up vector similarity search with pgvector for AI/ML embeddings, RAG applications, or semantic search.…
Use this skill for planning, testing, and safely executing PostgreSQL schema migrations — especially when working with production…
Use this skill to extract structured Markdown/JSON from PDFs and document images—tables with cell-level precision, formulas as…
Estimates intracellular metabolic fluxes from steady-state carbon-13 isotope-tracing measurements using validated atom maps,…