4 ms·
In the case of a blog though, there aren't many instances when you pull all the comments for every post. Tags, sure, but the most you normally need for comments
by apgwoz 17y ago
In the case of a blog though, there aren't many instances when you pull all the comments for every post. Tags, sure, but the most you normally need for comments is the count. There's two ways to approach this.
1) you use extra, or the new aggregate framework (that I haven't tested out)
2) you keep track of a comment_count in your Entry model and probably create a post_save callback on your Comment model.
The tags on the other hand are much more difficult, and I haven't figured out a great way to handle this except for saving a pre-rendered version of an entry, or saving a cached version of the tags as JSON (in addition to actually relating them) in the Entry instance. But, this of course means you need to jump through some other hoops to prepare this.
And all these hoops really speaks to ORMs not being very effective in all cases.