Open multiplegeorges opened 3 years ago
To write migrations, you have to create an additional migration file with proper :up
and :down
methods. You see what commands are needed between main branch and your changes and add to up/down methods.
Hi @multiplegeorges , I've noticed this as well even without the wild: true
modifier. Did you end up creating a PR or pushing a branch somewhere?
@trostli My fork is here https://github.com/multiplegeorges/acts-as-taggable-on/commits/master but it's wildly out of date at this point 😄
The changes are relatively minor so I bet it can be brought up to date pretty easily.
Hey all,
Thanks for the project! It's great.
I've noticed a performance issue with searching tags with
wild: true
in Postgres.For some reason, the query for wildcard tag names is structured like:
Using
LOWER
with ILIKE is unnecessary and makes it hard to set up a proper GIN/trigram index on tags.name. With a standard schema in Rails, you can't set up an index withLOWER(tags.name)
and I noticed that the pg planner wasn't using it anyway, though that may have been situational in my case.The solution is to change https://github.com/mbleigh/acts-as-taggable-on/blob/master/lib/acts_as_taggable_on/taggable/tagged_with_query/query_base.rb#L29 to:
and add an index on tags.name with:
I've been able to speed up wild tag name searches by 80+% this way.
I'd be happy to create a pull request that implements this change+index, but I'm not sure how you handle migrations and upgrading. If someone could help me out with that, I'll share my branch and we can make a PR from that.
Cheers, hope this helps someone!
Georges