Module query_analyzer

Module query_analyzer 

Source
Expand description

Query performance analysis and explain plans

This module provides tools for analyzing query performance, generating explain plans, and identifying optimization opportunities.

§Features

  • Query explain plans
  • HNSW traversal statistics
  • Filter selectivity analysis
  • Slow query identification
  • Performance profiling

§Usage

use vecstore::{VecStore, Query};
use vecstore::query_analyzer::QueryAnalyzer;

let store = VecStore::open("vectors.db")?;
let mut analyzer = QueryAnalyzer::new();

let query = Query::new(vec![0.1, 0.2, 0.3]).with_limit(10);

// Analyze query
let plan = analyzer.explain(&store, &query)?;

println!("HNSW nodes visited: {}", plan.nodes_visited);
println!("Distance calculations: {}", plan.distance_calculations);
println!("Filter selectivity: {:.2}%", plan.filter_selectivity * 100.0);
println!("Estimated cost: {:.2}ms", plan.estimated_cost_ms);

Structs§

QueryAnalyzer
Query analyzer for performance profiling
QueryPlan
Query execution plan with performance statistics
SlowQueryRecord
Slow query record