First of all form = SQLFORM.factory(db.mytable, record=db.mytable[myindex])
should probably be form = SQLFORM(db.mytable, record=db.mytable[myindex]) Anyway. The slow down is due to the IS_IN_DB(db, 'auth_user.id') validator. Every time you display the form, it will create a new dropdown list with all your users. You may want to cache this: Field('user_id', db.auth_user, requires=IS_NULL_OR(IS_IN_DB(db, 'auth_user.id ',cache=(cache.ram,3600))), ), 3600 means the list will be re-built every hour. On Sunday, 29 July 2012 04:53:25 UTC-5, weheh wrote: > > I've got an SQLFORM.factory inside a model. Very standard stuff: > > form = SQLFORM.factory(db.mytable, record=db.mytable[myindex]) > > The problem is, as I insert users into db.auth_user, the above > SQLFORM.factory statement takes longer and longer to execute. It begins by > executing in 0.05 seconds when there are only 3 rows in db.auth_user. > However, when db.auth_user grows to 10,000 rows, it takes 11.4 seconds to > do the above assignment. At 100,000 rows it takes over 2 minutes. > > Any ideas where the trouble is? The db.mytable does have a user_id field > that references auth_user: > > Field('user_id', db.auth_user, > requires=IS_NULL_OR(IS_IN_DB(db, 'auth_user.id')), > ), > > but I don't see how this could affect anything. This is a showstopper for > me, so any help would be appreciated. Thanks. > --