Query exists check