Optimizing Database Access

Be careful going down the query optimization path. Knowing that query takes "n.nn" seconds to execute only gives you part of the picture. A query that takes 2 seconds to run but that only gets executed twice a day is probably not worth examining. Bigger gains can usually be found by finding that query that gets executed 20 times on the same page. Or by identifying the function call that runs a query for each child rows instead of pulling in the all of the child rows by referencing the parent element in one query. Or taking it to the next level, caching the data on one page for use in other pages later in that user session.