Reduce the number of queries needed when loading extensions.

Extension loading would, at the worst case, attempt a fetch + create for
every extension. That create was only necessary the first time an
extension was loaded, and the rest of the time we'd just be doing a
fetch.

Doing one fetch per extension is a waste of time. Instead, we want to
fetch them all up-front, ideally.

This new code keeps track of what we need to fetch and what we need to
create. It then fetches all in one go, and then individually creates any
remaining registere extension entries we may need.