move long query out of core.