Performance problems of my rails application

ActiveRecord
I have a query which :include 3 associated model,I have test them,if i
include 2 of them the cost is low,about 0.x seconds,but the 3rd one will
cost 2-3 seconds if i include it,that is a relationship model which
contains (id,call_id,faq_id,created_on,updated_on,lock_version),why only
include this will rise my cost?just because of this table has two
foreign keys??

And I also found if change the multiple tables query into
find_by_sql,the performance is still poor,but if the query is executed
in MS query analyser then the response time is gonna be zero
So,all the time was spent on translating the data into object by rails?

I dont know how to optimize my application
Especially optimize the database operation via rails

Any suggestions?

Jin Han wrote:

that is a relationship model which
contains (id,call_id,faq_id,created_on,updated_on,lock_version),why only
include this will rise my cost?just because of this table has two
foreign keys??
Are the search keys indexed on the 3rd table?

So,all the time was spent on translating the data into object by rails?
Which database, environment, database driver are you using?

Joachim G. wrote:

Jin Han wrote:

that is a relationship model which
contains (id,call_id,faq_id,created_on,updated_on,lock_version),why only
include this will rise my cost?just because of this table has two
foreign keys??
Are the search keys indexed on the 3rd table?
Not yet,till now I did index any of the tables

So,all the time was spent on translating the data into object by rails?
Which database, environment, database driver are you using?
Sorry for my mistake
Production : MS SQL Server,Lighttpd,ADO.rb
Development : MS SQL Server,Mongrel,ADO.rb

looking forward to you