Thursday, 15 March 2012

php - Mysql: one large select statement? or multiple small statements? -



php - Mysql: one large select statement? or multiple small statements? -

just wondering what's best practice next in terms of efficiency.

i have table called "blogposts" several fields. have table called "comments" contains column blogpost_id.

there many comments 1 blog post.

i want retrieve info posts , sub-comments, improve seek , contain in 1 sql command this:

select * blogposts left bring together comments on blogposts.id = comments.blogpost_id

or improve select * blogposts

and select * comments blogpost_id=postid every post?

i should add together adding filters sql based on post , comment fields.

connecting database expensive. less it, better.

another way it, what's faster? making 1,000 trips drop off 1,000 boxes or 1 trip drop off 1,000 boxes?

php mysql

No comments:

Post a Comment