I am using rails, mongoid with mongohq on heroku to develop my site.
However, I got very serious performance issue.
I queried on each user page, it cost more than 2 seconds to load all the data The data are not that much, only like 30 musics and each music could have about 1 to 3 different styles.
Anyone knows how to improve the performance?
I have already tried a tons of methods but still not working and mongo shows each individual query is very fast.
Here's the code:
@musics = [] #get all user downloaded musics
@uploaders = [] #record uploader of each music
@styles = [] #record the styles of each music
@user.mydownloads.each do |download_music|
music = Music.find(download_music) #find the music by id
@musics.insert(0, music)
uploader = music.user #find the uploader
@uploaders.insert(0,uploader)
@styles.insert(0,shortstyle(music.music_styles,10))
#shortstyle is a helper function in application helper to make the stylelooks nicer
end
If all the data are required, how can i improve the performance?
Thank you guys very very much!