NewCode CLOUD — 20% off your first month on all cloud VPSClaim

TimescaleDB on Hong Kong VPS: Time-Series Data for Asia-Pacific (2026)

· 4 min read

TimescaleDB is a PostgreSQL extension that adds automatic partitioning (hypertables), time-series specific compression, and specialised query functions — enabling PostgreSQL to handle tens of millions of time-series rows efficiently. On a Hong Kong VPS, TimescaleDB stores financial tick data, IoT sensor readings, application metrics, or server performance data at scale, with full SQL and the familiar PostgreSQL toolchain.


TimescaleDB vs InfluxDB vs plain PostgreSQL

Factor TimescaleDB InfluxDB PostgreSQL
Query language Full SQL + time functions Flux / InfluxQL Full SQL
Relational joins Yes (it’s PostgreSQL) No Yes
Compression (time-series) 90–95% on old data Good No time-series compression
Continuous aggregates Yes — materialised views that auto-update Yes Manual
Ecosystem All PostgreSQL tools (pgAdmin, Grafana, etc.) Dedicated tooling Full PostgreSQL
Best for Time-series + relational data together Pure metrics/IoT Small-scale time data

Step 1: Install TimescaleDB

<code">apt install -y postgresql-16

# Add TimescaleDB repository
echo "deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -cs) main" \
  > /etc/apt/sources.list.d/timescaledb.list
wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | apt-key add -
apt update && apt install -y timescaledb-2-postgresql-16

# Run timescaledb-tune (auto-configures postgresql.conf for your VPS RAM)
timescaledb-tune --pg-config /usr/bin/pg_config --yes
systemctl restart postgresql

# Enable extension
sudo -u postgres psql << 'SQL'
CREATE DATABASE metrics_db;
\c metrics_db
CREATE EXTENSION IF NOT EXISTS timescaledb;
CREATE USER metrics_user WITH PASSWORD 'MetricsPass!';
GRANT ALL ON DATABASE metrics_db TO metrics_user;
SQL

Step 2: Create Hypertables

<code"># Connect and create your schema
sudo -u postgres psql metrics_db

-- Financial tick data table
CREATE TABLE trades (
    time        TIMESTAMPTZ NOT NULL,
    symbol      TEXT NOT NULL,
    price       NUMERIC(18, 8) NOT NULL,
    volume      NUMERIC(18, 8) NOT NULL,
    exchange    TEXT NOT NULL,
    side        TEXT CHECK (side IN ('buy', 'sell'))
);

-- Convert to hypertable (auto-partitioned by time)
SELECT create_hypertable('trades', 'time',
    chunk_time_interval => INTERVAL '1 day'  -- One partition per day
);

-- Index for fast symbol lookups
CREATE INDEX idx_trades_symbol_time ON trades (symbol, time DESC);

-- Server metrics table
CREATE TABLE server_metrics (
    time        TIMESTAMPTZ NOT NULL,
    host        TEXT NOT NULL,
    cpu_pct     FLOAT,
    mem_pct     FLOAT,
    disk_io_mb  FLOAT,
    net_rx_mb   FLOAT,
    net_tx_mb   FLOAT
);

SELECT create_hypertable('server_metrics', 'time',
    chunk_time_interval => INTERVAL '1 hour'  -- Hourly partitions for high-frequency data
);

Step 3: Insert and Query Data

<code"># Insert tick data
INSERT INTO trades (time, symbol, price, volume, exchange, side) VALUES
    (NOW(), 'BTC/USDT', 65432.10, 0.5, 'okx', 'buy'),
    (NOW() - INTERVAL '1 second', 'BTC/USDT', 65430.00, 1.2, 'binance', 'sell'),
    (NOW() - INTERVAL '5 seconds', 'ETH/USDT', 3521.50, 10.0, 'okx', 'buy');

-- Time-series specific queries:

-- OHLCV candlestick (1-minute bars)
SELECT
    time_bucket('1 minute', time) AS bucket,
    symbol,
    first(price, time) AS open,
    MAX(price)         AS high,
    MIN(price)         AS low,
    last(price, time)  AS close,
    SUM(volume)        AS volume
FROM trades
WHERE symbol = 'BTC/USDT'
  AND time > NOW() - INTERVAL '1 hour'
GROUP BY bucket, symbol
ORDER BY bucket DESC;

-- Moving average (20-period)
SELECT
    time,
    price,
    AVG(price) OVER (
        PARTITION BY symbol
        ORDER BY time
        ROWS BETWEEN 19 PRECEDING AND CURRENT ROW
    ) AS ma20
FROM trades
WHERE symbol = 'BTC/USDT'
ORDER BY time DESC
LIMIT 100;

-- Downsampled metrics (aggregate last 24h to 5-min buckets)
SELECT
    time_bucket('5 minutes', time) AS bucket,
    host,
    AVG(cpu_pct) AS avg_cpu,
    MAX(cpu_pct) AS max_cpu,
    AVG(mem_pct) AS avg_mem
FROM server_metrics
WHERE time > NOW() - INTERVAL '24 hours'
GROUP BY bucket, host
ORDER BY bucket DESC;

Step 4: Continuous Aggregates (Materialised Roll-ups)

<code"># Continuous aggregates: pre-computed, auto-refreshed roll-ups
-- 1-hour OHLCV materialised view (computed once, not per query)
CREATE MATERIALIZED VIEW trades_1h
WITH (timescaledb.continuous) AS
SELECT
    time_bucket('1 hour', time) AS bucket,
    symbol,
    first(price, time) AS open,
    MAX(price)         AS high,
    MIN(price)         AS low,
    last(price, time)  AS close,
    SUM(volume)        AS volume
FROM trades
GROUP BY bucket, symbol
WITH NO DATA;

-- Auto-refresh every 30 minutes, keep 1 year of hourly data
SELECT add_continuous_aggregate_policy('trades_1h',
    start_offset => INTERVAL '2 hours',
    end_offset   => INTERVAL '0',
    schedule_interval => INTERVAL '30 minutes'
);

-- Query the pre-aggregated view (very fast):
SELECT * FROM trades_1h
WHERE symbol = 'BTC/USDT'
  AND bucket > NOW() - INTERVAL '7 days'
ORDER BY bucket DESC;

Step 5: Data Retention and Compression

<code"># Compress data older than 7 days (typically 90-95% size reduction)
SELECT add_compression_policy('trades',
    compress_after => INTERVAL '7 days'
);

-- Check compression ratio
SELECT
    chunk_name,
    pg_size_pretty(before_compression_total_bytes) AS before,
    pg_size_pretty(after_compression_total_bytes)  AS after,
    ROUND(100 * (1 - after_compression_total_bytes::numeric /
          before_compression_total_bytes), 1) AS "compression_%"
FROM chunk_compression_stats('trades');

-- Auto-drop data older than 1 year
SELECT add_retention_policy('trades',
    drop_after => INTERVAL '1 year'
);

Step 6: Grafana Integration

<code"># TimescaleDB is fully Grafana-compatible via PostgreSQL data source
# In Grafana → Data Sources → PostgreSQL:
# Host: localhost:5432
# Database: metrics_db
# User: metrics_user

# Sample Grafana query for CPU dashboard panel:
SELECT
  time_bucket('$__interval', time) AS "time",
  host,
  AVG(cpu_pct) AS "CPU %"
FROM server_metrics
WHERE
  $__timeFilter(time)
  AND host IN ($host)
GROUP BY 1, 2
ORDER BY 1

Ingest Rate Benchmarks on HK VPS

VPS Spec Sustained inserts/sec Storage (1M rows, compressed)
2 GB / 2 vCPU 20,000–50,000 ~50–200 MB
4 GB / 4 vCPU 80,000–150,000 Same (CPU-bound)
8 GB / 8 vCPU + NVMe 200,000–400,000 Same (I/O-bound)

Conclusion

TimescaleDB on a Hong Kong VPS turns PostgreSQL into a high-performance time-series database — hypertables auto-partition data by time, continuous aggregates pre-compute roll-ups for instant dashboard queries, and columnar compression shrinks historical data by 90%+. For financial data platforms, IoT sensor networks, or application observability stacks targeting Asia-Pacific, TimescaleDB on a HK VPS combines the power of a purpose-built time-series engine with the familiar PostgreSQL ecosystem and full SQL expressiveness.

Store your time-series data: Browse Server.HK Hong Kong VPS plans — NVMe storage and ample RAM are key for TimescaleDB performance; a 4 GB plan handles most financial data and IoT workloads.

Related articles

More in VPS & ServersServer setup guides