veader/randumb — comment on commit b803ebefefa739d78d567839fbbcd2402ed3ef5c
File:  line 0
By spilliton:

This solution looks much cleaner, however I'm not sure it would perform better in the use case I use the most. This is when the initial results (id_results) are a rather large set and you only need a small subset of them. I believe that using shuffle on this large result set will cause rand() to be called N times because it has to shuffle the entire array of which you only need a few elements.

I would not be surprised though, if your solution performed better with smaller result sets. If we had some hard numbers we could make it pick the best algorithm for the job on each run based on the result set size and max_items.

When I get a chance, I'll do some timing comparisons, unless of course you feel like doing the benchmarking :)