Sébastien, Start by making something then when you will need performance you can work on it. I have 155 tables in my app and it is not the model that slow down things... It is more the number of records in these tables that matter so far... I mean, I should use SQLFORM.grid which use paging and load only small amount of records at a time which limit the loading time of grid page which are the page that requires the most processing. You better not define function or class in models files which really degrad performance. You can activate lazy table by respecting some rules when defining your table and set lazy table flag to true (this has no cost and should improve performance). You may also consider models/subfolder which make models file parsing conditionnal to the controller called though it has many chances to make your app less dry (I avoid that)... So as Steve mention there is "Model less app" for which you should found many thread on the mailing-list detailing how to use it. But as I said, just go that way once you really need it. It bring much more work for you and will slow down your pace of developpement if you do that too early.
Richard On Tue, Apr 14, 2015 at 8:03 PM, 黄祥 <steve.van.chris...@gmail.com> wrote: > yes, you are right, models executed on every request. but you can use, > model less application (define table using modules, best practice if you > have the same table that been used by more than 1 web2py app) or > conditional models (response.models_to_run) > In book you can see an advice : > > - Minimize the code in models: do not define functions there, define > functions in the controllers that need them or - even better - define > functions in modules, import them and use those functions as needed. > > > ref: > http://web2py.com/books/default/chapter/29/04/the-core#Conditional-models > > http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#Model-less-applications > > http://web2py.com/books/default/chapter/29/13/deployment-recipes#Efficiency-tricks > > best regards, > stifan > > -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > You received this message because you are subscribed to the Google Groups > "web2py-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.