in reply to Message Board Threading with DBI/MySQL

Better would be to have the root message and all its replies share a single value (e.g., root_msg_id) on which you have built an index.

Then you only need one select to pull them all in. You will still need to sort out the hierarchical relationships, but you've got parent_id, level_id, etc. in the table already.

Any benchmarking you do will indicate that one sql select is as slow as executing several hundred (if not thousand) lines of procedural code. The slight amount of thrashing in perl to sort things is more than made up for by eliminating all but the one select.

  • Comment on Re: Message Board Threading with DBI/MySQL