http://qs1969.pair.com?node_id=332478

jerrygarciuh has asked for the wisdom of the Perl Monks concerning the following question:

Honored monks,
I am in the last stages of creating an online curriculum tool using Class::DBI, Template-Toolkit, and CGI::Application. The administration tools are almost done. In our first migration from our dev server to the production server we are finding that performance is taking a hit. This is not as much of a concern for the admin tools as it is for the next piece of the puzzle the curriculum interface for students.

Our curriculum model has a very clean structure with all objects having a single parent object type and a single child object type. If speed were not a concern walking this structure is quite easy using CDBI. However, it involves quite a few record lookups, eg pull the pages for this section of this chapter and see if $page_number + 1 exists.

Since speed is a concern I am looking for alternatives for looking up a page id without having to potentially look up sections and chapters. My initial impulse is to alter the wizarding process for creating the curriculum so that it maintains a map of the whole structure of each curriculum as a var in a single record. I am imagining a hash that nests at each level the id for the current objects and an array of it's children. Each child also has it's id and the array of it's children. In this manner one could look up Curriculum 1, Chapter 3, Section 2, Page 5 or see if it has a page 6 and finding none go on to Section 3 or Chapter 4 etc. without multiple lookups in the db.

My question to you is what solutions have my betters applied to similar problems? If my solution has any merit please advise me of any gotchas you see.

TIA
jg

_____________________________________________________
"The man who grasps principles can successfully select his own methods.
The man who tries methods, ignoring principles, is sure to have trouble.
~ Ralph Waldo Emerson