V9: best way to update big lot of page handles

What’s the best way to update big lot of page handles:

  1. $page->update(array('cName' => $cName, 'cHandle' => $cHandle,));
  2. $db->executeQuery('UPDATE Collections SET handle = ? WHERE cID = ?', [$handle, $cid]);

Risk with #1 - php timeout.

Risk with #2 - Collections may be not the only table which has to be updated. CollectionVersions too? Any other?

Or any better way?

I tend to do any lengthy update like this with a custom console command in a package.