Practical tips to optimize Agno knowledge base performance, improve search quality, and speed up content loading.
Most knowledge bases work great with Agno’s defaults. But if you’re seeing slow searches, memory issues, or poor results, a few strategic changes can make a big difference.
What’s happening: Processing large files without batching, or using semantic chunking on huge datasets.Quick fixes:
Use skip_if_exists=True to avoid reprocessing
Switch to fixed-size chunking for faster processing
Process in batches instead of all at once
Use file filters to only process what you need
# Batch processing for large datasetsimport osdef load_content_in_batches(knowledge, content_dir, batch_size=10): files = [f for f in os.listdir(content_dir) if f.endswith('.pdf')] for i in range(0, len(files), batch_size): batch_files = files[i:i+batch_size] print(f"Processing batch {i//batch_size + 1}") for file in batch_files: knowledge.add_content( path=os.path.join(content_dir, file), skip_if_exists=True )
What’s happening: Loading too many large files at once, or chunk sizes are too large.Quick fixes:
Process content in smaller batches (see code above)
Reduce chunk size in your chunking strategy
Use include and exclude patterns to limit what gets processed
Clear old/outdated content regularly with knowledge.remove_content_by_id()
# Process only what you needknowledge.add_contents( paths=["large_dataset/"], include=["*.pdf"], # Only PDFs exclude=["*backup*"], # Skip backups skip_if_exists=True, metadata={"batch": "current"})
Learn how different chunking strategies affect performance
Vector Databases
Compare vector database options for your scale
Embedders
Choose the right embedder for your use case
Hybrid Search
Combine vector and keyword search for better results
Start simple, optimize when needed. Agno’s defaults work well for most use cases. Profile your application to find actual bottlenecks before spending time on optimization.