Claude Skill MartBrowse skillsQuick linesLearn by videoTerminal guideWhat is a Skill?
← Back to list

Migrate PostgreSQL Tables to Hypertables

A step-by-step playbook for converting existing PostgreSQL tables into TimescaleDB hypertables with optimal chunking, compression, and post-migration validation.

Data & AnalyticsAdvanced★ 1,865⑂ 113AI score 9/10Last updated: Oct 7, 2026

What it does

  • Picks the right configuration: lists candidate partition columns (timestamp, created_at, id...), and computes a chunk interval from index-size-per-hour so recent chunk indexes stay under ~25% of RAM (defaults to 7 days when unsure).
  • Checks constraints: verifies PK/UNIQUE constraints include the partition column and explicitly requires user approval before altering them. Flags Hypertable→Hypertable foreign keys as unsupported and stops the migration if they can't be dropped.
  • Plans execution: in-place create_hypertable for tables under 1GB, or a blue-green path (new hypertable → batched backfill → rename swap inside a maintenance window) for larger ones.
  • Configures columnstore compression: guidance for segmentby, orderby, sparse minmax indexes, and add_columnstore_policy.
  • Validates results: chunk/compression inspection queries, EXPLAIN (ANALYZE, BUFFERS) checks for chunk exclusion and ColumnarScan, insert-performance diagnosis via unused indexes, plus an ongoing monitoring view and pass/fail success criteria.

Who it's for

  • Backend and data engineers running PostgreSQL with fast-growing time-series, log, or event tables
  • Teams evaluating or newly adopting TimescaleDB who need a concrete conversion procedure
  • DBAs/SREs who must document a low-downtime migration plan for large tables

Example uses

  1. "Move our 120GB sensor_readings table to a hypertable with minimal downtime" → you get the blue-green sequence, batched backfill SQL, the rename transaction, and a rough duration estimate (~75k rows/sec).
  2. "What chunk interval should I use on a 64GB RAM box?" → it measures index growth per hour and recommends the largest interval that keeps 2+ recent chunk indexes under target.
  3. "Migration is done but compression is only 60%" → it inspects rows-per-segment in the newest compressed chunk to detect a bad segmentby choice and proposes new orderby/sparse indexes.

· · · Install guide · · ·

Try it now, no install

Paste this into Claude to use the skill without installing anything.

Read the instructions in this file and follow them to help me:
https://raw.githubusercontent.com/timescale/pg-aiguide/HEAD/skills/migrate-postgres-tables-to-hypertables/SKILL.md

What I want: (describe your task here)

If Claude can't open the link, open it yourself and paste the contents instead.

↓ If it works for you, download the ZIP below and install it. Then it runs on its own — no pasting each time.

Install in the Claude app (no terminal)
  1. Download the ZIP with the button below.
  2. In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
  3. Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
↓ Download ZIP
Install in Claude Code

Let Claude do it — paste this into Claude Code

Install the skill I found on Claude Skill Mart.
Copy the skills/migrate-postgres-tables-to-hypertables folder from the GitHub repo timescale/pg-aiguide into my ~/.claude/skills/migrate-postgres-tables-to-hypertables/.
When it's done, tell me in one line what this skill can do.

Install with a command instead

git clone https://github.com/timescale/pg-aiguide.git /tmp/pg-aiguide && mkdir -p ~/.claude/skills && cp -r /tmp/pg-aiguide/skills/migrate-postgres-tables-to-hypertables ~/.claude/skills/

⚠ This is a third-party skill. Check the source repository before installing.

  1. Open a terminal and clone the repository: git clone https://github.com/timescale/pg-aiguide.git
  2. Create the skills folder if needed: mkdir -p ~/.claude/skills
  3. Copy just this skill: cp -r pg-aiguide/skills/migrate-postgres-tables-to-hypertables ~/.claude/skills/
  4. (Optional) Also copy the companion skills find-hypertable-candidates and setup-timescaledb-hypertables from the same repo for the full candidate-to-config workflow.
  5. Restart Claude Code and trigger it with a request like "Migrate this table to a hypertable."
  6. Before running anything: confirm PostgreSQL 15+ with the TimescaleDB extension, take a database backup, and rehearse on staging since PK changes and FK drops are destructive.
View source on GitHub ↗License: Apache-2.0