RAG Query Optimization