Change SQL to improve performance.