Selecto.Performance.QueryAnalyzer (Selecto v0.3.16)

Query analysis and optimization using PostgreSQL's EXPLAIN ANALYZE.

Provides deep insights into query performance by:

  • Running EXPLAIN ANALYZE on queries
  • Parsing execution plans
  • Identifying performance bottlenecks
  • Suggesting optimizations
  • Tracking index usage

Link to this section Summary

Functions

Analyze index usage for a query.

Analyze a query using EXPLAIN ANALYZE and return detailed performance information.

Compare performance of two queries.

Get query plan without executing (EXPLAIN only, no ANALYZE).

Get statistics for tables used in a query.

Link to this section Functions

Link to this function

analyze_index_usage(selecto, options \\ [])

Analyze index usage for a query.

Link to this function

analyze_query(selecto, options \\ [])

Analyze a query using EXPLAIN ANALYZE and return detailed performance information.

options

Options

  • :format - Output format (:text, :json, :xml, :yaml). Default: :json
  • :analyze - Actually run the query (default: true)
  • :buffers - Include buffer usage (default: true)
  • :verbose - Include verbose output (default: false)
  • :timing - Include timing information (default: true)
  • :summary - Include summary (default: true)
  • :settings - Include settings (default: false)

examples

Examples

iex> QueryAnalyzer.analyze_query(selecto)
{:ok, %{
  execution_time: 45.2,
  planning_time: 0.8,
  plan: %{...},
  suggestions: [...]
}}
Link to this function

compare_queries(selecto1, selecto2, options \\ [])

Compare performance of two queries.

Link to this function

get_query_plan(selecto, options \\ [])

Get query plan without executing (EXPLAIN only, no ANALYZE).

Link to this function

get_table_statistics(selecto)

Get statistics for tables used in a query.