Live Queries
The Live Queries page is the primary view in IndeX-Ray. It connects to your database through the analyzer, pulls in every query tracked by pg_stat_statements, and runs each one through an optimization analysis — surfacing index recommendations, cost reductions, and augmented explain plans.
The query list
Section titled “The query list”The main view is a sortable table of all captured queries. Each row shows:
| Column | Description |
|---|---|
| Query | Cleaned SQL text (first two lines) |
| Status | Optimization state (see below) |
| Cost | Estimated cost reduction (baseline to optimized), if available |
| Nudges | Count of suggestions grouped by severity (critical, warning, info) |
| First Seen | When the query first appeared in pg_stat_statements |
| Mean Time | Average execution time in milliseconds |
| Calls | Total execution count |
| % of Runtime | Share of total database runtime |
Click any column header to sort. The default sort ranks queries by nudge severity so the most actionable queries surface first.
Queries sync from the database every 60 seconds automatically. Use the Refresh button to sync immediately.
Filtering
Section titled “Filtering”The left sidebar provides filters to narrow the list:
- Affecting Table — show only queries that touch a specific table
- Only SELECT queries — hide writes (INSERT, UPDATE, DELETE)
- Filter out system queries — hide queries against
pg_*andinformation_schema - Filter out targetless queries — hide SELECTs without a
FROMclause (e.g.SELECT 1) - Only improved queries — show only queries where optimization found a better plan
- Status — multi-select to show/hide specific optimization states
All filter preferences persist in your browser across sessions.
Optimization states
Section titled “Optimization states”Each query goes through an optimization pipeline. The status column reflects its current state:
| Status | Meaning |
|---|---|
| Waiting | Queued for analysis |
| Optimizing | Currently being analyzed |
| Improvements available | Found index recommendations with a cost reduction |
| No improvement found | Query is already optimal given the current schema |
| Not supported | Query type can’t be optimized (e.g. DDL, utility) |
| Timeout | Analysis exceeded the time limit |
| Error | Analysis failed |
The status bar at the bottom of the page shows overall progress: how many queries have been processed, how many have improvements, and how many are still waiting.
Query detail
Section titled “Query detail”Clicking a query opens a detail view with four sections:
Metadata
Section titled “Metadata”Top-left panel showing the query’s key metrics: status, cost, mean time, calls, runtime share, and first-seen date.
Insights
Section titled “Insights”Top-right panel containing:
- Nudges — optimization suggestions grouped by severity (critical, warning, info), with full explanations
- Suggested indexes — concrete
CREATE INDEXrecommendations when improvements are available - Tables accessed — every table the query touches
- Indexes used — indexes referenced in the current plan, linked to the Indexes page
- Tags — SQLCommenter metadata (source file, route, method) if present
Formatted query
Section titled “Formatted query”Bottom-left panel with the SQL text, annotated inline with nudge markers showing exactly where in the query each suggestion applies.
Explain plan
Section titled “Explain plan”Bottom-right panel with the query’s execution plan. When improvements are available, you can toggle between the Baseline plan (current schema) and the Optimized plan (with suggested indexes applied) to see the difference.
Three view modes are available:
- Tree — interactive visual tree with expandable nodes, showing augmented fields like cost breakdowns, alternative plans, ineligible indexes, and order analysis
- ASCII — text-based tree for quick scanning or copy-pasting
- JSON — raw explain plan output
Use the previous/next arrows (or keyboard arrows) in the detail header to navigate through your filtered query list without returning to the table.
Toolbar actions
Section titled “Toolbar actions”- Refresh — manually trigger a sync from the database
- Export to JSON — download all queries with improvements as a JSON file
- Reset queries — clear
pg_stat_statementson the source database (see source code mapping for when this is useful) - Settings — configure your IDE preference for clickable file links