Yii Framework Forum: AR vs DAO - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

AR vs DAO Rate Topic: -----

#1 User is offline   rpaulpen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 136
  • Joined: 01-December 08

Posted 09 December 2008 - 11:27 AM

Hi all,

I understand the usability differences between Active Record and DAO, but need a better understanding of performance in a very large database/high traffic environment.  Assuming the code is optimized in either case, can one assume DAO has less overhead, is faster  and would be more conducive to a high traffic environment?

I'm no expert on the topic, but looking for some advice.

Regards,

R
0

#2 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,900
  • Joined: 04-October 08
  • Location:DC, USA

Posted 09 December 2008 - 11:42 AM

Because AR is built on top of DAO, it is definitely slower than using DAO directly. However, the overhead is expected to be very small, because it is mainly caused by data population. Compared with the cost needed by query execution (often in the scale of 100ms or higher), this overhead (at 10ms or smaller scale) should be negligible.

0

#3 User is offline   rpaulpen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 136
  • Joined: 01-December 08

Posted 11 December 2008 - 07:57 AM

Thanks Qiang.

A project I'm working on will require full text search.  Instead of trying to write some algorithm to control the details, I'm thinking of using mySQL's full text search feature. 

I would prefer to use AR in the application vs DAO.  I sometimes have difficultly understanding the limitations of AR, so wonder if it would allow mySQL's full text search capabilities using Post::model()->findBySql($sql,$params).

Thanks,

R
0

#4 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,900
  • Joined: 04-October 08
  • Location:DC, USA

Posted 11 December 2008 - 08:23 AM

I think it should work (findBySql). But if not, you can always declare a static method in your AR class and call DAO to accomplish your goal. By doing so, all DB-query-related code are placed inside models, which helps organize your code.
0

#5 User is offline   rpaulpen 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 136
  • Joined: 01-December 08

Posted 11 December 2008 - 12:57 PM

OK, thanks Qiang.

R
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users