EXPLAIN(7) SQL Commands EXPLAIN(7) NAME EXPLAIN - SYNOPSIS EXPLAIN [ ANALYZE ] [ VERBOSE ] statement DESCRIPTION PostgreSQL --- --- EXISTS LIMIT ANALYZE Important: ANALYZE EXPLAIN SELECT INSERTUPDATEDELETE EXECUTE EXPLAIN ANALYZE BEGIN; EXPLAIN ANALYZE ...; ROLLBACK; PARAMETERS ANALYZE VERBOSE PostgreSQL VERBOSE explain_pretty_print statement SELECT, INSERT, UPDATE, DELETE, EXECUTE, DECLARE NOTES PostgreSQL Section 13.1 ``Using EXPLAIN'' PostgreSQL ANALYZE ANALYZE PostgreSQL 7.3 NOTICE EXAMPLES int4 10000 EXPLAIN SELECT * FROM foo; QUERY PLAN --------------------------------------------------------- Seq Scan on foo (cost=0.00..155.00 rows=10000 width=4) (1 row) WHERE EXPLAIN EXPLAIN SELECT * FROM foo WHERE i = 4; QUERY PLAN -------------------------------------------------------------- Index Scan using fi on foo (cost=0.00..5.98 rows=1 width=4) Index Cond: (i = 4) (2 rows) EXPLAIN SELECT sum(i) FROM foo WHERE i < 10; QUERY PLAN --------------------------------------------------------------------- Aggregate (cost=23.93..23.93 rows=1 width=4) -> Index Scan using fi on foo (cost=0.00..23.92 rows=6 width=4) Index Cond: (i < 10) (3 rows) EXPLAIN EXECUTE PREPARE query(int, int) AS SELECT sum(bar) FROM test WHERE id > $1 AND id < $2 GROUP BY foo; EXPLAIN ANALYZE EXECUTE query(100, 200); QUERY PLAN ------------------------------------------------------------------------------------------------------------------------- HashAggregate (cost=39.53..39.53 rows=1 width=8) (actual time=0.661..0.672 rows=7 loops=1) -> Index Scan using test_pkey on test (cost=0.00..32.97 rows=1311 width=8) (actual time=0.050..0.395 rows=99 loops=1) Index Cond: ((id > $1) AND (id < $2)) Total runtime: 0.851 ms (4 rows) PostgreSQL-- ANALYZE ANALYZE COMPATIBILITY SQL EXPLAIN Postgresql man man https://github.com/man-pages-zh/manpages- zh SQL - Language Statements 2003-11-02 EXPLAIN(7)