Stop Using `ORDER BY RANDOM()`: It Scans the Whole Table
·6 mins
The /random_search endpoint ran two full-table queries on every request. A 10-minute TTL cache materialized the 30k preferred-printing list once; individual requests then did an in-memory sample. Zero DB round-trips on the hot path.