EXPLAIN
A diagnostic command provided by relational databases that shows the execution plan the query optimizer selects for an SQL statement, including access methods, join order, algorithms and cost.
Timeline (last 90 days)
EXPLAIN is a relational database diagnostic command used to show the execution plan chosen by the query optimizer, including table access methods, join order, join algorithms, and estimated row counts and costs.
A cost-proxy method for detecting Cartesian products: count the row count of each referenced table and sum them, switch to multiplying when a join without ON or USING is encountered, and reject the query if the threshold is exceeded.
The EXPLAIN command makes the database return the query's execution plan without actually executing the query, and can be used to check for performance hazards such as full table scans and Cartesian products.
Redshift query plans can be obtained via EXPLAIN or EXPLAIN ANALYZE, showing the scan method, join order, join type, and whether data redistribution or broadcast occurs.
The official PostgreSQL reference documentation records EXPLAIN and privilege rules, and teams should read the page for their corresponding version before copying grants, because default privileges may vary by version.
On PostgreSQL, you can create a read-only role (such as agent_reader) and grant CONNECT, USAGE, and SELECT privileges, then check the query plan via SET ROLE and EXPLAIN, without granting write privileges.
SQLite's EXPLAIN returns the bytecode instruction sequence of the underlying virtual machine (VDBE).
All Facts (7)
EXPLAIN is a relational database diagnostic command used to show the execution plan chosen by the query optimizer, including table access methods, join order, join algorithms, and estimated row counts and costs.
50%UnverifiedA cost-proxy method for detecting Cartesian products: count the row count of each referenced table and sum them, switch to multiplying when a join without ON or USING is encountered, and reject the query if the threshold is exceeded.
50%UnverifiedThe EXPLAIN command makes the database return the query's execution plan without actually executing the query, and can be used to check for performance hazards such as full table scans and Cartesian products.
50%UnverifiedRedshift query plans can be obtained via EXPLAIN or EXPLAIN ANALYZE, showing the scan method, join order, join type, and whether data redistribution or broadcast occurs.
50%UnverifiedThe official PostgreSQL reference documentation records EXPLAIN and privilege rules, and teams should read the page for their corresponding version before copying grants, because default privileges may vary by version.
50%UnverifiedOn PostgreSQL, you can create a read-only role (such as agent_reader) and grant CONNECT, USAGE, and SELECT privileges, then check the query plan via SET ROLE and EXPLAIN, without granting write privileges.
50%UnverifiedSQLite's EXPLAIN returns the bytecode instruction sequence of the underlying virtual machine (VDBE).
50%