Updating few thousand nodes in one time I have script which updating 2000-5000 nodes in loop and performance is poor.
At the moment the code looks like:

foreach($nids as $nid) {
  $node = node_load($nid);
  // updating $node fields
  node_save($node);
}


It's possible optimize it? I don't need revisions, call node_* hooks, just update data.
There's a module called Views Bulk Operations.

This will update more than thousand node at a time without memory limit exception.