I have the following code:
team_articles = user.npt_teams.to_a.inject({}) {|arts,team|
arts.merge({ team.name =>
NptArticle.join(:npt_authors).join(:users).join(:npt_teams).where(:npt_teams__id => team.id).to_a.uniq})
}
It causes my my terminal to stop responding and my macbook to slow down.
In mysqlworkbench it get's a response instantly.
A potential suggestion is to create a lighter version of the NptArticle object but I'm not quite sure how to create a version that pulls less columns so any suggestion to fix this issue would be great.
edit:
As requested, The table
second edit:
As requested, the generated sql:
SELECT * FROM `npt_articles` INNER JOIN `npt_authors` INNER JOIN `users` INNER JOIN `npt_teams` WHERE (`npt_teams`.`id` = 1)
I'd love to upgrade the ruby version but I can't, I'm simply working off an old code-base and this is what version of ruby it uses. There are plans to re-build in the future with more modern tools but at the moment this is what I have to work with
Aucun commentaire:
Enregistrer un commentaire