efficiency

Script Optimizations

Well, I just finished updating a script that was very inefficient for work. It is true that form and optimization come after function, but neither should be neglected long-term.

Originally the script was written to display a list of documents (with numerous links and attributes), with anchored headers for each group. The scripts took as input the ID for the section of docs to be listed. The database call was a good efficient call with 'Order By' sorting, three levels deep. But the original author then ignored the doc order and started looping through the docs looking for all the docs that belonged in each header section. Then the next header would be started and the whole list would be looped through again, only picking the other docs that matched that heading. Easily this works out that you must go through the entire record set a number of times equal to the number of headers.

Syndicate content