AR performance advice needed

I’ve seen in a few posts people to hint about different performance of AR and DAO approach. Can someone explain where exactly is the bottle neck of the performance compromise in AR cases. Is it in the default select? What would be the difference in performance between:

AR approach:


Model::model()->findAll(array(

   'select'=>'id',

   'condition'=>'condition_rule',

))

and


$connection=new CDbConnection($dsn,$username,$password);

$connection->active=true;

$sql="SELECT id FROM table WHERE condition_rule";

$dataReader=$connection->createCommand($sql)->query();

....

Cheers,

b

Put simple: AR always has to build the SQL for you and that creates some overhead. I think it depends on the complexity of what you try to do with AR. In my projects i usually use AR and know that if the app has performance issues i can still switch to DAO to squeeze out some more miliseconds per request. It’s up to you to find these bottlenecks in your app. You could use performance profiling to investigate.

Edit: Oh, and not to forget the additional time required to parse the query result into your AR objects.