scientiffic
scientiffic

Reputation: 9415

ActsAsTaggable Tagging Table is Huge

I have a Rails app that's using the acts_as_taggable gem. I hosted the app on Heroku and found that I exceeded the rows limit for their free PostgreSQL database.

Looking at the tables automatically generated using the gem, my Tags table has 3302 rows, but my Taggings table has a whopping 17103 rows.

I'm trying to figure out why there's this huge discrepancy and if there's anything I can do to reduce the Taggings table size. Are there any best practices for this?

Upvotes: 0

Views: 50

Answers (1)

Vasfed
Vasfed

Reputation: 18504

17103 taggings for 3302 tags does not look that whopping - every tag at average is assigned to 5 entities.

Look into:

  1. are there tag duplicates that can be merged? or duplicate taggings (the gem should take care of this, but just in case)
  2. Are there any dangling taggings (where entity is already deleted, or should be deleted because the user is long gone etc.)
  3. Do you really need normalized tags? In some cases you can replace the whole thing with postgres arrays inside entity tables.

Upvotes: 1

Related Questions