Issue #23254:improve query