# Performance problems of my rails application

**URL:** <https://www.ruby-forum.com/t/performance-problems-of-my-rails-application/111513>\
**Category:** Rails\
**Created:** [August 8, 2007, 5:40am UTC](https://www.ruby-forum.com/t/performance-problems-of-my-rails-application/111513 "2007-08-08T05:40:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@jin](https://www.ruby-forum.com/u/jin)\
**Post date:** [August 8, 2007, 5:40am UTC](https://www.ruby-forum.com/t/performance-problems-of-my-rails-application/111513/1 "2007-08-08T05:40:56Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@jin](https://www.ruby-forum.com/u/jin)\
**Post date:** [August 8, 2007, 9:39am UTC](https://www.ruby-forum.com/t/performance-problems-of-my-rails-application/111513/2 "2007-08-08T09:39:13Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/4af34b/32.png) [@jin](https://www.ruby-forum.com/u/jin)\
**Post date:** [August 8, 2007, 10:07am UTC](https://www.ruby-forum.com/t/performance-problems-of-my-rails-application/111513/3 "2007-08-08T10:07:44Z")

</div>

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
