RAG optimization