On restore, all the communication with the backup_ids_temp table happens using these two lowlevel functions:
being called "zillions" of times for storing/retrieving records from that table.
It would be great to have some cache (by backupid, itemname, itemid), caching results on retrieval and invalidating them on store. Surely one separate singleton-like instance. Should improve speed in restore a lot!