Skip to content
Discussion options

You must be logged in to vote

To maintain sub-10ms query latency on high-volume scan analytics in PostgreSQL:

  1. Composite Index on Scan Logs:
CREATE INDEX idx_qr_scans_code_time ON qr_scans (qr_id, scanned_at DESC);

This enables rapid aggregation for time-series charts (hourly/daily views) without sequential table scans.

  1. Partitioning:
    For systems exceeding 100k scans/day, partition the qr_scans table by month using PostgreSQL range partitioning:
CREATE TABLE qr_scans (
    id UUID NOT NULL,
    qr_id UUID NOT NULL,
    scanned_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
    user_agent TEXT,
    ip_hash VARCHAR(64)
) PARTITION BY RANGE (scanned_at);
  1. Asynchronous Ingestion:
    Decouple immediate redirection f…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by bitzin-dev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant