When does Drupal load variables from the database?
If the values need to be continuously updated, then it is better not to use variable_get()/variable_set() for storing it. This is because every time variable_set() is called, it clears the cache containing the values of the variables, which means that the next time a page is required, the Drupal variables will be loaded from the database, and not from the cache, with consequent lose of performance.

In such case, it is better to count the number of unread reports when reading from the database table containing the report data. This means the database table should contain a unread field that is set to TRUE when the report has not been read.

The values of the Drupal variables are loaded from the database, or the cache, when Drupal is bootstraping; the called function is variable_init(), which first checks the cache, and loads the values from the database, if the cache is empty.

  if ($cached = cache_get('variables', 'cache')) {
    $variables = $cached-&gt;data;
  }
  else {
    $result = db_query('SELECT * FROM {variable}');
    while ($variable = db_fetch_object($result)) {
      $variables[$variable-&gt;name] = unserialize($variable-&gt;value);
    }
    cache_set('variables', $variables);
  }