Answers you can trust, from Codeables

Every page on Codeables is structured and verified — built so people and the AI agents they rely on can trust it. Explore more from the source behind this answer.

Explore Codeables
Verified Source
Time-Series Databases

How do I store high-ingest IoT sensor data in SQL without constantly re-partitioning tables?

TigerData8 min read

Most teams hit the same wall with IoT: your SQL database starts fast, then ingest slows, indexes bloat, and you’re stuck constantly adding new partitions just to keep writes and queries alive. You don’t actually have a “SQL problem”—you have a partitioning and storage problem that plain Postgres doesn’t automate well at telemetry scale.

This is exactly the class of workload TigerData is built for: keep Postgres as-is (SQL, drivers, ecosystem), but add time-series primitives—automatic partitioning, time-aware storage, and compression—so you can ingest high-volume sensor data without babysitting table partitions.

Quick Answer: Use hypertables (automatic time-based partitioning), row-columnar storage, and tiered storage in TigerData’s Postgres platform to handle high-ingest IoT data. You keep standard SQL and schemas while the database automatically manages partitions, compression, and cold storage—no manual re-partitioning loops.


The Quick Overview

  • What It Is: A Postgres-native platform (Tiger Cloud + TimescaleDB extension) that turns a single table into a hypertable: automatically partitioned, compressed, and tiered for IoT-scale ingest.
  • Who It Is For: Teams running high-ingest sensor, telemetry, or time-series workloads that want to stay on SQL/Postgres without managing a custom partitioning scheme or a separate real-time stack.
  • Core Problem Solved: Plain Postgres tables become slow and expensive under billions of time-ordered inserts, forcing you into manual partitioning and fragile streaming pipelines. TigerData replaces that with automatic partitioning and storage policies inside Postgres.

How It Works

At the core is the hypertable abstraction. You define your logical table once (for example, iot_readings), then convert it to a hypertable. TimescaleDB automatically:

  • Partitions data into time-based chunks in real time
  • Keeps recent chunks “hot” for fast ingest and queries
  • Lets older chunks be compressed and moved to cheaper storage

All of this happens behind a standard Postgres interface. Your app still does:

INSERT INTO iot_readings (device_id, ts, temperature, humidity) VALUES (...);
SELECT * FROM iot_readings WHERE device_id = 'sensor-123' AND ts > now() - interval '1 hour';

Under the hood, TigerData handles the mechanics that you’d otherwise script with manual partitions.

  1. Hypertable creation (automatic partitioning):
    You start with a normal table and convert it:

    CREATE TABLE iot_readings (
      device_id    text NOT NULL,
      ts           timestamptz NOT NULL,
      temperature  double precision,
      humidity     double precision,
      status       text
    );
    
    SELECT create_hypertable('iot_readings', 'ts', 'device_id', 4);
    
    • ts is your time column (primary partition key)
    • device_id is an optional space partition key to spread load across devices
    • TimescaleDB automatically creates and manages underlying chunks; you don’t schedule CREATE TABLE ... PARTITION OF ... manually.
  2. Hot ingest and indexing:
    Inserts are written almost entirely into the most recent chunks. Because each chunk is time-ordered and has its own indexes:

    • Locks are localized; high ingest won’t stall the entire table.
    • You can size chunks so recent ones fit in memory, keeping writes and queries fast.

    A typical index strategy looks like:

    CREATE INDEX ON iot_readings (device_id, ts DESC);
    

    Important: With hypertables, you don’t need to re-create indexes on every new partition—indexes are managed across chunks for you.

  3. Lifecycle management (compression, tiering, and retention):
    Once ingest is stable, you automate the data lifecycle:

    • Compression: Convert older chunks to compressed, columnar storage.
    • Tiered storage: On Tiger Cloud, older compressed chunks move to low-cost object storage while remaining queryable.
    • Retention: Drop data beyond a certain age if you don’t need it.

    Example policies:

    -- Compress data older than 7 days
    SELECT add_compression_policy('iot_readings', INTERVAL '7 days');
    
    -- Drop data older than 365 days
    SELECT add_retention_policy('iot_readings', INTERVAL '365 days');
    

    Compression can reduce storage by up to 98% on typical telemetry, and it transforms big historical ranges into columnar scans optimized for aggregations.


Features & Benefits Breakdown

Core FeatureWhat It DoesPrimary Benefit
HypertablesAutomatically partition tables into time-based chunks at ingest timeNo manual re-partitioning; stable ingest and queries as data grows
Hypercore row-columnar storageStores recent data in row form; compresses older data into columnar formatFast writes for live data; fast scans and aggregates for historical analytics
Tiered storage & policiesMoves cold, compressed chunks to low-cost object storage with retention rulesKeep years of IoT data online at a fraction of the cost while keeping a single SQL interface

Ideal Use Cases

  • Best for continuous IoT sensor streams: Because it automates time-based partitioning, indexing, and retention for workloads ingesting millions to trillions of rows per day. You design the table once; the database manages chunking and lifecycle policies as new data arrives.

  • Best for real-time dashboards + long-term analytics: Because row-based hot chunks power “last 5 minutes” queries, while columnar compressed chunks power “last 12 months by site” rollups—both in the same table, via SQL.


Limitations & Considerations

  • Schema still matters:
    Hypertables don’t “fix” a poor schema. You still need a clear time column, appropriate primary keys, and well-chosen indexes. For very high ingest, avoid wide rows with dozens of high-cardinality text columns; consider splitting dimensions into reference tables when they don’t change often.

  • Not a silver bullet for arbitrary OLTP:
    TigerData is optimized for time-ordered workloads (append-mostly or append + occasional updates). If your workload is dominated by random updates/deletes across the entire keyspace without a time dimension, hypertables may not provide as much benefit.


Pricing & Plans

TigerData runs as a managed service (Tiger Cloud) with transparent, usage-based billing. You pay for provisioned compute and storage; there are:

  • No per-query fees
  • No extra line items for automated backups
  • No ingest/egress surcharges for normal operation

Plans are typically grouped by workload profile:

  • Performance: Best for teams starting to outgrow a single Postgres instance and needing predictable ingest for IoT or metrics data. You get managed operations, automated backups, and the core hypertable/features needed to stop hand-rolling partitioning logic.

  • Scale / Enterprise: Best for organizations running mission-critical telemetry at very large scale (billions to trillions of events per day), or with compliance needs. You add HA, read replicas, multi-AZ deployments, SOC 2 reporting, GDPR support, and HIPAA on Enterprise, plus 24/7 support with SLA-backed response times.

Note: Exact SKUs, instance sizes, and regional availability are published on TigerData’s site; usage is billed monthly in arrears with itemized breakdowns.


Frequently Asked Questions

How do hypertables help me avoid constant re-partitioning?

Short Answer: Hypertables automate partition creation and routing so your table transparently becomes a set of time-based chunks; you never manually add partitions or rewire your application.

Details: In plain Postgres, once your sensor table reaches tens or hundreds of millions of rows, you start partitioning manually:

CREATE TABLE iot_readings_2025_01 PARTITION OF iot_readings
  FOR VALUES FROM ('2025-01-01') TO ('2025-02-01');

You repeat this for every month (or day), adjust indexes, and maintain scripts to create future partitions. If ingest grows, you reconsider partition sizes and repeat the process.

With TimescaleDB:

  • create_hypertable tells the extension which column is time.
  • TimescaleDB automatically creates, sizes, and manages chunks as data arrives.
  • Insert routing is transparent; your app still writes to iot_readings.
  • You tune chunk size globally instead of managing hundreds of individual partitions.

Engineers who follow the best-practice pattern—“write mostly to the most recent chunks and keep them in memory”—see stable write performance without periodic re-partitioning work.

Can I keep everything in SQL while still integrating with Kafka/S3 or a lakehouse?

Short Answer: Yes. You keep Postgres as the primary interface while ingesting from Kafka/S3 and optionally replicating to Iceberg, without building a separate streaming stack.

Details: Many IoT teams end up with fragile glue:

  • Kafka + stream processors (e.g., Flink) to land data
  • Custom jobs to sync into Postgres for querying
  • Separate ETL to a data lake or warehouse for long-term analytics

TigerData’s approach is to keep Postgres at the center:

  • Ingest from Kafka/S3 directly into hypertables.
  • Use the same SQL interface for operational queries, analytics, and AI/ML workloads (via extensions like pgvector/pgai).
  • Replicate into an Iceberg-based lakehouse when you need that pattern—without manually maintaining multiple, divergent schemas.

The net effect: you collapse multiple systems into a Postgres-native stack, reduce operational complexity, and keep data modeling in SQL.


Summary

You don’t need to abandon SQL—or hand-build a complex partitioning scheme—to store high-ingest IoT sensor data at scale. The right approach is to extend Postgres with time-series primitives:

  • Hypertables for automatic, time-based partitioning
  • Row-columnar storage for fast ingest and fast analytics on the same table
  • Tiered storage and policies for compression, retention, and cost control

TigerData packages these capabilities as a managed Postgres platform for live telemetry. You keep the “boring, reliable, endlessly extensible” foundation of Postgres while eliminating fragile, high-maintenance partition scripts and streaming glue.


Next Step

Get Started