A tagging plugin for Rails applications that allows for custom tagging along dynamic contexts.
4.97k
stars
1.2k
forks
source link
Use exists clause over IN Tag.for_context, Tag.for_tenant to improve performance #1087
Closed
aovertus closed 2 years ago
Looking at documentation and articles it seem that
IN
is only beneficial on really small dataset.If anyone as deeper understanding of
IN
overEXISTS
. It looks like more recent engine handle those query the same way.The same strategy exists for https://github.com/mbleigh/acts-as-taggable-on/blob/master/lib/acts_as_taggable_on/taggable/tagged_with_query/any_tags_query.rb#L20-L22
Here is the example we ran into production which generated performance issues
Engine:
MySQL 5.7
Dataset
~ 7_000_000 taggins records ~ 1300 tags
Current implementation
Query run in ~ 58.74s
Patch
Query run in ~ 149ms