Repository navigation
What database indexing strategy is recommended for high-volume QR scan analytics? #5
Answered
by
bitzin-dev
bitzin-dev
asked this question in
Q&A
|
When a QR code receives thousands of scans per hour, how should the database tables be structured and indexed to prevent query degradation on the dashboard? |
Answered by
bitzin-dev
Nov 26, 2026
Replies: 1 comment
|
To maintain sub-10ms query latency on high-volume scan analytics in PostgreSQL:
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.
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);
|
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
To maintain sub-10ms query latency on high-volume scan analytics in PostgreSQL:
This enables rapid aggregation for time-series charts (hourly/daily views) without sequential table scans.
For systems exceeding 100k scans/day, partition the
qr_scanstable by month using PostgreSQL range partitioning:Decouple immediate redirection f…