Skip to content

Extremely slow queries when using #tagged_with a lot of tags #293

tanelsuurhans opened this Issue Oct 8, 2012 · 2 comments

3 participants


I have a situation when one model has two different context for tags and those are used in a search filtering system. When im searching for 10+ tags with #tagged_with(tags, :on => :context), the amount of joins done (one join for each tag) makes the query close to unexecutable. I literally cannot even get an explain output with mysql for the query. Oddly enough, when im cutting the joins to like below 10, it works fast. Anyone experienced this or has an idea how to solve it?


I'm facing the same issue. Your pull request did seem to improve the performance, but even so ActiveRecord takes a lot of time to return anything.


@mogelbrod are you able to paste a SQL EXPLAIN showing where the slowdown is?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.