Ruby On Rails is slow…?

后端 未结 11 1912
说谎
说谎 2021-01-31 23:50

I\'m writing a web application to monitor a furniture factory production flow. It has thousand of data to handle. So far, I run RoR on Mongrel + MySQL and it\'s really really sl

11条回答
  •  轮回少年
    2021-02-01 00:18

    How many of those 0-10ms queries are being executed per view access? What parts of your data model are being referenced? Are you using :include to get eager loading on your associations?

    Rails is as slow as you make it. With understanding comes speed (usually!)

    Expanding on the above, do you have has_many associations where, in particular, your view is referencing the "many" side without an :include? This causes your find(:all) on the master table to be executed with a join to the detail - if you have large numbers of detail records and are processing all of them individually, this can get expensive.

    Something like this:

    Master.find(:all, :include => :details)
    

    ...might help. Still guessing from sparse info, though.

    There's an old Railscast on the subject here

提交回复
热议问题