I don't understand when a computed field computes. Does it compute when the fields it draws on are updated or when someone views the node it's used in?
From Computed Field Module:
Computed Field is a very powerful CCK field module that lets you add a custom "computed fields" to your content types. These computed fields are populated with values that you define via PHP code. You may draw on anything available to Drupal, including other fields, the current user, database tables, you name it. (Feeling the power yet? :) ) You can also choose whether to store your computed field values in the database with other content fields, or have them "calculated" on the fly during node views. (Although you should note that Views use requires database stored values.) This field is literally the Swiss Army knife of CCK fields. So start cooking up your PHP based values!
In the documentation page ( http://drupal.org/node/126522 ) it also says:
When is the field actually computed?
If you wish to store the values in the database then you have to update or re-submit the node to compute the value of the field.
If it is not stored in the database then the value computes when the node loads and only when the node is loaded. The field will not work in views nor will it function properly if it depends on other non-stored computed fields.
More information from drupal.org and what appears to be a good page of snippets is http://drupal.org/node/149228
These days (more then 3 years after this question was asked), there is a NOT commonly known/used alternative available for the Computed Field module, i.e. the (fairly new) Math Field module (for D7). Some more details about this module (from its project page), which also details when the calculations actually happen:
The Math Field module defines a new field type to dynamically calculate values on entity forms. This is an alternative to Computed Field that does not require the use of PHP Filter.
For more details (step-by-step instructions), refer to either of these links:
- the (amazing!) Community documentation about the Math Field module.
- the interesting article about Introducing the Math Field module, which also includes some screenprints to see it at work (such as the the add/edit form example).
As this is a fairly new D7 module, there are still a few (known) issues with it, as mentioned also on its project page:
- The cTools math expression library causes an error when using function that take more than one parameter. This effects pow(), min(), max() (#1958538: Improve math expression engine).
- Math Field does not yet support multivalue options fields (checkboxes, or multiselect) (#2483453: Add aggregate functions for multivalue fields).
- Math Field does not yet support Field Collections (#2573643: Support the Field Collection module).
Bonus: you would not need the "PHP filter" (IMO only that should be a valid reason to investigate this alternative) ...