Reputation: 413
I have started using Yii2. I got following question: Active Record or Query Builder? Which should I use? Which is working faster? Thank you.
Upvotes: 0
Views: 1355
Reputation: 1268
Do not overuse Active Record. Although Active Record is good at modeling data in an OOP fashion, it actually degrades performance due to the fact that it needs to create one or several objects to represent each row of query result. For data intensive applications, using DAO or database APIs at lower level could be a better choice.
It's from Yii2 Performance Tuning
Upvotes: 3
Reputation: 291
You should always use models with ActiveRecord and use Query Builder when necessary only.
There no big performance differences between the both but ActiveRecord can save you alot of time while you are developing your app
Upvotes: 3