How to know when and whether SQL query optimization is required