Forum: Ruby on Rails Solution for multilanguage caption lookup speed improvement?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
02e5064be65a36d46d46992c382509ea?d=identicon&s=25 Marcus Ob (mrqzzz)
on 2006-02-11 00:33
Hello.
In my Rails app i have a helper method called "translate":

def translate(name)
  tran = Translation.find_by_name(name)
  ...
  ...
end

As you can see, the method does a lookup in the table "Translation",
where i have an index in the field "name".
This is working well, but in a single page i can have dozens of captions
to translate, and there are several concurrent users, so the whole thing
slows a bit.
I guess preloading the Translation table in a Hashtable would help, but
i wouldn't load this hash table in each user session: how can i use a
single Hashtable per Server instance ?


Also, with many users i -randomly- have a "MySQL lost connection
error".I guess finding a solution for the lookup could avoid having this
problem.

Thanks,
Marcus.
This topic is locked and can not be replied to.