4 ms·
Why hit the network/a central resource when you could just do it locally?
by placeybordeaux 10y ago
Why hit the network/a central resource when you could just do it locally?
- drewbug 10y agoSometimes, it'll be faster.
- placeybordeaux 10y agoUnless you specify some asymmetry it will always be faster to do it locally.
- fouc 10y agoIt's a webapp, they're likely already querying all the meal information from a mysql or postgresql db. Chances are they could have made a change to their db models and written some sql to handle food requirements checking instead of handling it after the query. But that could've been premature optimization ultimately, and to speed it up now, it's probably easier to optimize the slow ruby code with some rust instead.
- hobs 10y agoExactly, I dont mean to beat a dead horse, but most bog standard web apps have the quoted items in a db anyway, and these are very common problems. For example if we have a few tables we can determine which menu items a user could eat: users user_ingredient_exclusions ingredients menu_ingredients menu -- items a user can eat based on not having any items in the excluded list select distinct m.* from menu m inner join menu_ingredients mi on m.id = mi.menu_id left join user_ingredient_exclusions e on e.ingredient_id = mi.ingredient_id inner join user u on u.id = e.user_id where e.id is null and u.id = @id