wiki:DeveloperGuidelines/Optimisation

Version 10 (modified by Fran Boon, 12 years ago) ( diff )

Explicit select example

Optimisation

Writing code which runs fast.

Consider having configurations which are read from DB frequently but written-to rarely, be set in configuration files which are written-out from the DB (like the CSS from themes)

Specific Examples

for i in range(0, len(rows)):
     row=rows[i]

runs much faster than:

 for row in rows:

(0.05 vs. 0.001 seconds in a test case).


value = table[id].field

runs 1.5x faster than:

value = db(table.id==id).select(table.field, limitby=(0,1))[0]

(0.012 vs. 0.007 seconds vs in a test case)

Profiling


DeveloperGuidelines

Note: See TracWiki for help on using the wiki.