[web2py] Re: Avoiding extra quries when using DAL

2013-06-05 Thread guruyaya
The toolbar wasn't helpful, as this is a json script, and I didn't want to screw with user experiance. Also, the db._timings, I think, is not relevant to GAE. I used it and showd 0 queries. But, I've used appstats, and found there's no extra query, so I guess I'll have to search for the big

[web2py] Re: Avoiding extra quries when using DAL

2013-06-04 Thread Anthony
for entity in db(db.table2.id 0).select(): retVal += entity.table1.name No, web2py does not retrieve entity.table1.name when the first line above is executed. Rather, it does a separate select when the second line is executed. entity.table1 is a DAL Reference object -- when you access

[web2py] Re: Avoiding extra quries when using DAL

2013-06-04 Thread Massimo Di Pierro
I would replace retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.table1.name with table1_map = db(db.table2 http://db.table2.id/).select().as_dict() retVal = [table1_map[entity.table1].name http://entity.table1.name/ for entity in db(db.table2

Re: [web2py] Re: Avoiding extra quries when using DAL

2013-06-04 Thread Carlos Costa
Hum, I forgot the problem has two tables. Nice! 2013/6/4 Massimo Di Pierro massimo.dipie...@gmail.com I would replace retVal = [] for entity in db(db.table2.id 0).select(): retVal += entity.table1.name with table1_map = db(db.table2 http://db.table2.id/).select().as_dict() retVal

[web2py] Re: Avoiding extra quries when using DAL

2013-06-04 Thread guruyaya
OK, so I could be wrong about this. Is there a way to get the number of GAE datastore reads per request? On Tuesday, June 4, 2013 12:25:06 PM UTC+3, guruyaya wrote: Lets examine this code for a sec: db.define_table('table1',Field('name')) db.define_table('table2',Field('table1', db.table1),

[web2py] Re: Avoiding extra quries when using DAL

2013-06-04 Thread Anthony
{{=response.toolbar()}} includes a button for all the queries and their execution times (this is also available as a list of 2-tuples in db._timings). Anthony On Tuesday, June 4, 2013 10:05:49 AM UTC-4, guruyaya wrote: OK, so I could be wrong about this. Is there a way to get the number of