Ruby threads

I have been tasked with speeding up a method which is very slow. I have considered using threads for some of it along with other optimizations. I haven’t worked with threads before and there are a few things I’m not certain about regarding their use and practicality. This is a rails 4.0 ruby 2.0 site. One thing I wanted to know was, if part of the problem is the number of SQL quries this method runs, is using threads worth it given that SQL operations as I understand it are blocking calls? The SQL isn’t the only reason this thing is slow, but it is one of the main reasons. I am aware of what “race conditions are” and the importance of keeping things in sync but many of these queries just contribute to the content of the page independent of one another rather than depending on each other directly.

Any pointers would be helpful. Thanks

Not sure how much help I can be here, but before you start considering using threads, might it not be worth looking at the queries themselves to see if they can be made more efficient?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.