Reduce the number of SQL calls

Less calls to the database usually results in improved application performance.

In the simplest case, if you need to select from multiple tables, try to issue a single select statement that selects everything at one time rather than issuing separate select statements.

A more non obvious case is in an action that potentially processes multiple transactions in a loop. You may need to update an object based on the outcome of business logic. It is more efficient to make one update at the end of the action to update all objects (or sets of objects) than it is to issue an update statement for each object as you iterate over the objects. It is more efficient to update all objects or sets of objects once, at the end of the action, than it is to issue an update statement for each object as you iterate over the objects.

The generic action A_RouteAndSendOutTxn is a good example of this optimization. After sending the outbound transaction, if a response is expected, the object TIMEOUT value must be set to a future time. As the action runs, it builds a list of object IDs that must be updated and, at the end of the action, issues a single update statement.