Slashcode Log In
Efficient implementation of nested comments
I looked into SlashCode and while I don't grok Perl at all, I figured that it's querying all article's comments at once and then does the rest of processing in Perl (which I was unfortunately unable to follow).
For my site I created something completely different: I send an SQL query to the DB for every nesting level. This means about 5-8 queries for a typical page of my site (the peak was on a page with around 170 comments, where it needed 10 queries). Yes, the DB has more to do, but the results are such that I only have to layout them recursively, without any sorting or searching whatsoever.
My questions: has anyone done any research into efficient database layouts and clever SQL-queries (wrt to nested comments) that would extract as much as possible without forcing to much work on PHP/Perl/Java side? Also, what is the better solution - extract all comments in one go and then process them or rather have multiple queries returning better formed data sets (assuming fast database like MySQL)? Thanks."