Coder Social home page Coder Social logo

Comments (4)

bradeaton avatar bradeaton commented on September 21, 2024

Just pinging on this question again... My main question is about tags on existing records. Our application is multi-tenant in the same DB. There is an accounts table and a contacts table. The contacts table has an account_id column. If I add acts_as_taggable_tenant :account_id to the contact model, will all the tags on existing contacts records benefit from this or would I have to delete the tags from each contact and add them back?

from acts-as-taggable-on.

NurfitraPujo avatar NurfitraPujo commented on September 21, 2024

Hello @bradeaton i know this is old post but anyway, our team also use this gem for tagging conversation rooms in our application. There is one heavy query that do aggregates on our model (rooms count by tag). This query can process up to 8 millions row at once so itu is very slow before optimi zed (~30s) and now it becomes ~5s.

My comments on your query is:

  1. Just select the necessary columns
  2. Make sure to create multicolumn index that consisted of all columns used in your where clause. include columns that used in your select and join keys

from acts-as-taggable-on.

darkamenosa avatar darkamenosa commented on September 21, 2024

I faced the almost same problem. It seems the best way is to create a new column on the table and store the cached tag. And query on that table not using these tables. (Ref: https://github.com/mbleigh/acts-as-taggable-on/wiki/Caching

I'm testing with my local, hope this works.

from acts-as-taggable-on.

sumirolabs avatar sumirolabs commented on September 21, 2024

Another solution is to add a new scope that reproduces the original query, eg

scope :with_tag, lambda {|tag| joins(:taggings).where(taggings: { tag_id: tag.id }) }

and then replace the tagged_with calls with this scope.

It would be nice to add the option of passing in an actual tag (instead of the name) and then use the query in the scope above.

from acts-as-taggable-on.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.