Check pool eligibility with an unordered sample, not a full-pool sort

Performancekamo-shared-library
Shipped
September 16, 2026 at 5:48 PM UTC
Author
Kamo
Commit
b6f7163

hasEligibleAssignableLead only needs to know whether any pool lead is one the member may take, but it read a page of findAssignablePool, whose ORDER BY assigned_date has no index and sorts the entire pool before the LIMIT. The leads-available endpoint calls it per product on every availability event; with the US farm pools growing it held the database tserver at its 16-core limit. Measured in production on a 16k-lead pool: 1276 ms sorted vs 18 ms unordered. Acceptance keeps the ordered query.

All changes

Like what you see shipping?

All of it arrives in your workspace on its own. Start on the free plan and read this page again in a month.

Start Free ForeverView Pricing