Re: Inefficient SQL queries with hasMany/belongsTo relationship

2009-10-28 Thread robustsolution
the question why do you want to paginate comments while you are paginating posts? in general when you paginate the main model (Post), you just include summary fields from the associated models example -last commented by commenter name -last comment title... not body... (text) -last commented in (d

Re: Inefficient SQL queries with hasMany/belongsTo relationship

2009-10-23 Thread bonecandy
On Oct 23, 7:43 pm, Miles J wrote: > Im curious as how you think a join would be better? You are you going > to grab multiple comment rows for a single post, while paginating > posts? 2 queries is faster then sub-queries. > > More queries is sometimes better than complex queries. Well, you may c

Re: Inefficient SQL queries with hasMany/belongsTo relationship

2009-10-23 Thread Miles J
Im curious as how you think a join would be better? You are you going to grab multiple comment rows for a single post, while paginating posts? 2 queries is faster then sub-queries. More queries is sometimes better than complex queries. --~--~-~--~~~---~--~~ You rec

Re: Inefficient SQL queries with hasMany/belongsTo relationship

2009-10-23 Thread Andras Kende
You might want to look into : http://book.cakephp.org/view/816/counterCache-Cache-your-count Andras On Oct 23, 2009, at 7:30 PM, bonecandy wrote: > >> How slow. Feel free to propose an alternative that achieves the same >> thing. > > Okay, well, I researched IN again and it appears that IN i

Re: Inefficient SQL queries with hasMany/belongsTo relationship

2009-10-23 Thread bonecandy
> How slow. Feel free to propose an alternative that achieves the same > thing. Okay, well, I researched IN again and it appears that IN is really only slow in sub-selects where a join would be much faster. Sorry, I posted without double-checking, I conflated sub-selects with any select ;( > So

Re: Inefficient SQL queries with hasMany/belongsTo relationship

2009-10-23 Thread Céryl
Probably because he doesn't know about recursion (yet)? A find('all') command will do exaclty that, find all... So if you do a find('all') of the posts, itll also get all the commens, tags, users, whatever the post has relationships with... If in a certain action you just need the posts, add $this

Re: Inefficient SQL queries with hasMany/belongsTo relationship

2009-10-23 Thread AD7six
On 23 oct, 05:32, bonecandy wrote: > Hi, this is my first post here - I'm new to CakePHP, but not to > programming or PHP. > Anyway, to get acquainted with Cake I've been making a blog (I know, > crazy, huh?). So, I have my posts table and model, which has a hasMany > relationship with comments

Inefficient SQL queries with hasMany/belongsTo relationship

2009-10-22 Thread bonecandy
Hi, this is my first post here - I'm new to CakePHP, but not to programming or PHP. Anyway, to get acquainted with Cake I've been making a blog (I know, crazy, huh?). So, I have my posts table and model, which has a hasMany relationship with comments, and my comments table and model, which has a b