Short-Circuiting Correlated Subqueries in SQLite
emschwartz.me·1d·
🗄️Databases
Preview
Report Post
  • 16 Dec, 2025 *

I recently added domain exclusion lists and paywalled content filtering to Scour. This blog post describes a small but useful SQL(ite) query optimization I came across between the first and final drafts of these features: using an uncorrelated scalar subquery to skip a correlated subquery (if you don’t know what that means, I’ll explain it below).

Scour searches noisy sources for content related to users’ interests. At the time of writing, it ingests between 1 and 3 million pieces of content from over 15,000 sources each month. For better and for worse, Scour does ranking on the fly, so the performance of the ranking database query directly translates to page load time.

The Ranking SQL Query

The main SQL query Scour uses for ranking app…

Similar Posts

Loading similar posts...