Move database operations to a separate thread.