ORM generating too many queries

Hi,

I have a situation using ORM something like php activerecord. Reason for this is :

  • I have a table for articles that table is related to :
  1. articlesi18n (for multilanguage)
  2. article_type (for type of article)
  3. article_comment (comments on article)

so for each instance of db record i have minimum 3 queries. So on main section page when i display 30 or 40 articles i get total of num*3 queries.
This is huge overload because minimum per page i can get is around 150 :slight_smile: That is realy too much. How do you guys solve this problem.

I guess loading everything on some kind of join is a good start, i want to hear your ideas.

Thank you :*

You should probably look into a caching system. ORMs are notorious for excessive queries. Its one of the major draw backs of using such a system. Is this your own home grown ActiveRecord or open source project?

It’s my own orm much like php activerecord but i kind of changed and strip lots of thing that i don’t need on my project just so i can speed it up. I was thinking when creating object to load in multiple join all thing needed and store them. I guess it’s the only way.

php activerecord has eager loading capabilities using “includes”. Check it out, I think its what your after.

Are you using any framework?