3 ms·
For something that is in memory and throw-away, why go through a DB?
by bjz_ 10y ago
For something that is in memory and throw-away, why go through a DB?
- hobs 10y agoI was taking the point of "Why is the problem taking so long when it seems like a simple thing to calculate?" which was a little orthonogal from theme of the total post, so I can see why there would be some confusion. The article talked about 30 minutes to run through a "is this set of items in this other set of a bunch of items". While it would probably make sense to do this efficiently in memory the reality is the company mentioned are probably doing it inefficiently in memory; asking some tool which can do this type of work effectively and is fairly well known was my basic suggestion.
- placeybordeaux 10y agoWhy 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