Richard Penman
How to make web2py faster

26 Nov 2011

Avoid regenerating tables:

  
db = DAL('sqlite://storage.sqlite', migrate=runonce)

Create indexes:

  
db.executesql('CREATE INDEX IF NOT EXISTS {table}_index ON {table} (id);'.format(table=table))

Compile byte code in admin

Serve static files direct from server

Move as much logic as possible from models into controllers and modules

Disable session if possible

Cache database queries and controller functions:

  
@cache(request.env.path_info, time_expire=5, cache_model=cache.ram)
def index():
    db().select(db.log.ALL, cache=(cache.ram, 60))
blog comments powered by Disqus