Remix.run Logo
▲ koolba 4 hours ago

That’s pretty funny! I’ve seen optimizations like this for reporting systems where rather than taking the top N item matching filter X, they cheat by taking the top M (where M > N) items and then filter it client side to N items matching filter X.

As long as the results are enough to populate the page you don’t notice the difference and it’s usually faster as you reuse the prior ranking.

But if not, you get this exact situation.

▲zahlman 3 hours ago | parent [-]

I assume the reason this is faster is because they cache for specific values of M?

▲shermantanktop an hour ago | parent [-]

Imagine the filter is not trivial but instead involves deep inspection of each item and calls to an external service. Bounding the max number of expensive calls and enabling parallelism is more important than returning exactly the requested number of items.

For a real world example, imagine a personalized search query that ranks and filters based on the user’s history.