Query Analyzer

Quickly analyze an SQL command, without any instrumentation
The Query Analyzer is designed to analyze SQL queries using their execution plans. The tool takes an SQL command and its corresponding execution plan as input and provides insights into the query's performance, potential optimization opportunities, and any issues that might affect its execution.
The Query Analyzer analyzes various aspects of the query, such as the tables and indexes used, the join and filtering conditions, the order of operations, and the estimated and actual number of rows returned. It also provides recommendations for optimizing the query, such as adding or modifying indexes, rewriting the query, or modifying the schema design.
The Query Analyzer is a simple and great solution for analyzing a small number of SQL Commands. To analyze SQL commands at scale, such as your entire QA scenarios use Metis SDK.

Step 1 - Paste the SQL Command

This step is pretty straightforward. Open the Query Analyzer and paste the SQL Command. Or, if you just want to get a better understanding of the tool, you can try one of the built-in examples
select *
from postgres_air.flight
where flight_id = 108340

Step 2 - Retrieve the Execution Plan

The SQL command instructs the DB engine what data to return while the execution plan is a set of instructions on how to execute the query. The execution plan is generated by the database engine and provides detailed information including the order of operations, the tables and indexes accessed, the join and filtering conditions, and the estimated and actual number of rows returned by each operation. The execution plan is essential for understanding the performance characteristics of a query and identifying potential optimization opportunities.
There are two types of execution plans: estimated and actual. We recommend using the actual one. For more details about the differences between the two types see Metis Building Blocks or PostgreSQL documentation.
The execution plan must be created using one of the following commands:
Actual - EXPLAIN (ANALYZE, COSTS, VERBOSE, BUFFERS, TIMING, FORMAT JSON)
Estimated - EXPLAIN (COSTS, VERBOSE, BUFFERS, FORMAT JSON)
For ex. The code below generates the actual execution plan of the query as JSON.
EXPLAIN (ANALYZE, COSTS, VERBOSE, BUFFERS, TIMING, FORMAT JSON)
select *
from postgres_air.flight
where flight_id = 108340
The execution plan looks similar to this:
{
"Plan": {
"Node Type": "Index Scan",
"Parallel Aware": false,
"Scan Direction": "Forward",
"Index Name": "flight_pkey",
"Relation Name": "flight",
"Schema": "postgres_air",
"Alias": "flight",
"Startup Cost": 0.42,
"Total Cost": 8.44,
"Plan Rows": 1,
"Plan Width": 71,
"Output": [
"flight_id",
"flight_no",
"scheduled_departure",
"scheduled_arrival",
"departure_airport",
"arrival_airport",
"status",
"aircraft_code",
"actual_departure",
"actual_arrival",
"update_ts"
],
"Index Cond": "(flight.flight_id = 108340)",
"Shared Hit Blocks": 0,
"Shared Read Blocks": 0,
"Shared Dirtied Blocks": 0,
"Shared Written Blocks": 0,
"Local Hit Blocks": 0,
"Local Read Blocks": 0,
"Local Dirtied Blocks": 0,
"Local Written Blocks": 0,
"Temp Read Blocks": 0,
"Temp Written Blocks": 0,
"I/O Read Time": 0,
"I/O Write Time": 0
},
"Planning": {
"Shared Hit Blocks": 0,
"Shared Read Blocks": 0,
"Shared Dirtied Blocks": 0,
"Shared Written Blocks": 0,
"Local Hit Blocks": 0,
"Local Read Blocks": 0,
"Local Dirtied Blocks": 0,
"Local Written Blocks": 0,
"Temp Read Blocks": 0,
"Temp Written Blocks": 0,
"I/O Read Time": 0,
"I/O Write Time": 0
},
"Planning Time": 0.066
}

Step 3 - Run Query Analyzer

Make sure you pasted both the SQL and its execution plan and click on Submit.
The web app will show you the query analysis.