RFID Ingestion
Taming a 585-million-row scan table | CheckPoint Business Intelligence | private company project, sanitized
context
Fixed RFID readers at the gates talk a binary TCP protocol to a Python ingest server, which stages every read in SQL Server; stored procedures then turn the reads into worker sessions and scan logs. At peak the readers fed it about 3,900 reads per second, roughly 234,000 rows a minute.
problem
Most of those reads carried no new information: readers scan continuously, so the same badge is seen again and again by the same reader, or lands inside a session the processor would ignore anyway. Each one still cost a database insert. The staging table had grown to 585 million rows (506 GB), every insert also paid for index maintenance, the database files shared the operating-system drive, and there was no backup schedule.
what I did
- Added sliding-window deduplication in the ingest server, keyed on reader and tag, so repeat scans inside the window never leave the process.
- Added a cooldown pre-filter in the batcher that mirrors the processor's session cooldown, and a filter for tags assigned to nobody, so scans the processor would reject never reach the database.
- Kept the database off the hot path: reads append to a lock-free JSONL disk buffer and a separate batcher thread bulk-inserts them into SQL Server, with replay after a restart.
- Dropped two non-clustered indexes from the write-heavy staging table, cutting per-insert cost an estimated 2-3x, and set a 70% fill factor on high-write tables.
- Moved SQL Server data and log files to dedicated storage and added SQL Server Agent jobs: daily full backups with a 14-day retention, log backups every 30 minutes, a batched cleanup procedure, index rebuilds and a weekly integrity check.
- Hardened access: the built-in admin login disabled and the application login cut down to least privilege.
- Later gave the ingestor its own repository and deploy pipeline, removed the credential defaults from the imported code and pinned its dependencies, and wrote the postmortem when an unindexed retention delete grew the transaction log to about 471 GB and starved the ingestor.
stack
Python TCP SQL Server T-SQL SQL Server Agent Windows Server
outcome
- Database inserts cut by an estimated 60-80% (an engineering estimate from the optimization work, not a measured benchmark).
- The 585M-row staging table cleared; it now works as a lean staging buffer.
- The database went from no backups to full backups plus 30-minute log backups on dedicated storage.
Sanitized case study -- no client identifiers, hostnames, endpoints, or credentials.