News for hackers. Stuff that matters.
Re:Algorithms Every Programmer Should Know: Reservoir Sampling by practicalpants on Friday March 06, 2015 @01:38PM (#9158648)
I think in any real life scenario I would have an idea about the number of records in my table, or could figure that out very cost effectively. So to follow in OP's example with Rails, I would just do Table.where(id: [array_of_random_ids]), which is going to be extraordinarily more efficient than his batch processing Table.find_all.

Something should really only be filed under "Every Programmer Should Know" if it will be encountered in the real world more than once or twice. So in this case, the title feels like click-bait.

Re:Algorithms Every Programmer Should Know: Reservoir Sampling by syntern on Friday March 06, 2015 @03:00PM (#9159221)
Reservior sampling does have legitimate use in monitoring: to track real-time percentiles (e.g. over the last 15 minutes), without logging everything and re-calculating on each new data entry. I do think it is important and useful to know about it, but probably would not use it for the database sampling (as it was in the article).