RAG system optimization