Pardon my Ruby/Rails ignorance, I'm still learning.
Details:
I have two mongodb tables. people
has 214 records, people_org
has 107, this will only increase in the future. The only unique connection between these tables is a person's name, which is on average ~15 characters. I do not have control over this DB structure at this time.
Currently I'm looping through each people
object, then using find_by
to find the matching record, printing an ID that I need, and printing some information.
<%@people.each do |p|%>
...
<%=@people_org.find_by(name: p.name).id%>
...[priting a few paragraphs of text]...
<%end%>
...
<%end%>
Problem:
The performance is quite slow (~10 seconds).
Potential Solutions:
(1) Our team may adapt to a structure that does not rely on string matching and use integers instead (I assume this would improve performance).
(2) Perhaps there is a more efficient method?
(3) Perhaps there is a way to prepare or alter the data for a more effcient sort?
Thank you in advance for your help.