Closed gr-eg closed 3 years ago
We have run in to a performance issue when removing unused tags and not using the tags_counter
tags_counter
taggings.count.zero? executes the following sql
taggings.count.zero?
`SELECT COUNT(*) FROM taggings WHERE taggings.tag_id = ?`
This can be very slow on large tables
by using taggings.none? it instead executes:
taggings.none?
`SELECT 1 AS one FROM taggings WHERE taggings.tag_id = 304185392 LIMIT 1`
which can always use the index and is much faster.
released
We have run in to a performance issue when removing unused tags and not using the
tags_counter
taggings.count.zero?
executes the following sqlThis can be very slow on large tables
by using
taggings.none?
it instead executes:which can always use the index and is much faster.