Move nsql publishing to its own thread.

Publishing was hanging the main lua update thread.
Is 'pub' only used here? Make it local?