A Survey of Query Optimization in Large Language Models