Changes between Version 31 and Version 32 of DeveloperGuidelines/Optimisation
- Timestamp:
- 06/18/10 08:07:03 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DeveloperGuidelines/Optimisation
v31 v32 89 89 These "rules" might seem a matter of course, however, sometimes you need to take a second look at your code: 90 90 91 1. '''Use joins''': 91 === Use Joins === 92 92 93 93 One complex query is usually more efficient than multiple simple queries (and gives the DB server a chance to optimize): … … 108 108 }}} 109 109 110 2. '''Ask exactly for what you expect''' (=limit your query): 110 === Limit your Query === 111 111 112 If you expect only one result, then limit the search by limitby:112 Ask exactly for what you expect - if you expect only one result, then limit the search by limitby: 113 113 114 114 {{{ … … 134 134 }}} 135 135 136 3. '''Don't ask twice for the same record'''. 136 === Don't ask twice... === 137 137 138 Look down your code whether your need the same record again later:138 ...for the same record. Look down your code whether your need the same record again later: 139 139 140 140 {{{ … … 153 153 }}} 154 154 155 4. '''Don't loop over queries''', if you can avoid id. 155 === Don't loop... === 156 156 157 Sometimes it is not as easy to see as in the following example:157 ... over queries if you can avoid id. Sometimes it is not as easy to see as in the following example: 158 158 159 159 {{{