Changes between Version 52 and Version 53 of DeveloperGuidelines/Optimisation


Ignore:
Timestamp:
06/18/10 10:03:34 (11 years ago)
Author:
Dominic König
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • DeveloperGuidelines/Optimisation

    v52 v53  
    201201}}}
    202202
    203 The nested case:
    204 
    205 {{{
    206 for id in ids:
    207   record1 = db(db.table1.id == id).select().first()
    208   if record1 and record1.some_attribute == some_value:
    209     record2 = db(db.table2.id == record1.some_key).select().first()
    210     if record2:
    211         ...
    212 }}}
    213 
    214 ...if there is nothing to else to do with the table1 records, try instead:
    215 
    216 {{{
    217 query = (db.table1.id.belongs(ids)) & \
    218         (db.table1.some_attribute == some_value) & \
    219         (db.table2.id = db.table1.some_key)
    220 rows = db(query).select(db.table2.ALL)
    221 for record2 in rows:
    222     ...
    223 }}}
    224 
    225203----
    226204DeveloperGuidelines