On Friday, December 30, 2011 4:22:29 AM UTC-5, Joseph Jude wrote: > > Let us say I have the below code in db.py under models > > define_table(db, ....) > > If I change that to, > if settings.migrate: > define_table(db,...) > > rest of the queries based on this table doesn't work. I want to skip the > definition altogether if the table is already present. Reason: I assume > that GAE makes a datastore call for each of these define_table. So every > page request initiates these define_table adding to the cost of datastore > read limits posed in GAE. Is this how it happens? Can I skip definition of > tables altogether? (I believe django doesn't invoke definition of tables > for every request) >
The table definition creates the table model for web2py to use, so you cannot skip the table definition if your application code needs to do anything with that table model during the request. I don't think merely calling define_table should result in a datastore hit (I'm not totally sure about that on GAE, but in non-GAE environments, define_table won't touch the db, unless it results in a migration happening). I'm not sure why you have so many reads. Maybe check to see if you're doing any recursive selects: http://web2py.com/books/default/chapter/29/6#Recursive-selects. Anthony