Difference between revisions of "EXPLAIN (PostgreSQL)"
Jump to navigation
Jump to search
↑ https://www.postgresql.org/docs/9.1/sql-explain.html
Tags: Mobile web edit, Mobile edit |
|||
(18 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
https://www.postgresql.org/docs/current/sql-explain.html | https://www.postgresql.org/docs/current/sql-explain.html | ||
− | <code>EXPLAIN | + | <code>EXPLAIN</code> show the execution plan of a statement |
.../... | .../... | ||
Line 10: | Line 10: | ||
Planning Time: 0.441 ms | Planning Time: 0.441 ms | ||
Execution Time: 50387.333 ms | Execution Time: 50387.333 ms | ||
+ | |||
+ | ==Simple query on a table with a single integer column and 10000 rows== | ||
+ | <ref>https://www.postgresql.org/docs/9.1/sql-explain.html</ref> | ||
+ | <pre>EXPLAIN SELECT * FROM foo; | ||
+ | |||
+ | QUERY PLAN | ||
+ | --------------------------------------------------------- | ||
+ | Seq Scan on foo (cost=0.00..155.00 rows=10000 width=4) | ||
+ | (1 row)</pre> | ||
+ | |||
+ | [[JSON]] formatting: | ||
+ | |||
+ | EXPLAIN (FORMAT JSON) SELECT * FROM foo; | ||
+ | QUERY PLAN | ||
+ | -------------------------------- | ||
+ | [ + | ||
+ | { + | ||
+ | "Plan": { + | ||
+ | "Node Type": "Seq Scan",+ | ||
+ | "Relation Name": "foo", + | ||
+ | "Alias": "foo", + | ||
+ | "Startup Cost": 0.00, + | ||
+ | "Total Cost": 155.00, + | ||
+ | "Plan Rows": 10000, + | ||
+ | "Plan Width": 4 + | ||
+ | } + | ||
+ | } + | ||
+ | ] | ||
+ | (1 row) | ||
== Related terms == | == Related terms == | ||
* [[Bitmap scan]] | * [[Bitmap scan]] | ||
− | * [[EXPLAIN ANALYZE]] | + | * [[EXPLAIN ANALYZE (MySQL)]] |
+ | * [[EXPLAIN ANALYZE (PostgreSQL)]] | ||
+ | * [[WAL]] | ||
+ | * [[pg_statistic]] | ||
+ | * [[PostgreSQL parallel query]] | ||
== Activities == | == Activities == |
Latest revision as of 14:11, 14 April 2022
https://www.postgresql.org/docs/current/sql-explain.html
EXPLAIN
show the execution plan of a statement
.../... -> Index Scan using your_key on your_table your_table (cost=0.43..8.39 rows=1 width=952) (actual time=1.030..1.030 rows=0 loops=39649) Index Cond: (id = your_id) Filter: (your_filter_id = ######) Rows Removed by Filter: 1 Planning Time: 0.441 ms Execution Time: 50387.333 ms
Contents
Simple query on a table with a single integer column and 10000 rows[edit]
EXPLAIN SELECT * FROM foo; QUERY PLAN --------------------------------------------------------- Seq Scan on foo (cost=0.00..155.00 rows=10000 width=4) (1 row)
JSON formatting:
EXPLAIN (FORMAT JSON) SELECT * FROM foo; QUERY PLAN -------------------------------- [ + { + "Plan": { + "Node Type": "Seq Scan",+ "Relation Name": "foo", + "Alias": "foo", + "Startup Cost": 0.00, + "Total Cost": 155.00, + "Plan Rows": 10000, + "Plan Width": 4 + } + } + ] (1 row)
Related terms[edit]
- Bitmap scan
- EXPLAIN ANALYZE (MySQL)
- EXPLAIN ANALYZE (PostgreSQL)
- WAL
- pg_statistic
- PostgreSQL parallel query
Activities[edit]
See also[edit]
- SQL, NewSQL, RDMS: GraphQL (2015), SQLite,
select, insert
,select count
, Distributed SQL, TablePlus, Cache hit ratio,pg_stat_user_tables
,EXPLAIN
, Index (PostgreSQL), DDL, SQL/MED, Group by, List users, SQL Injection, SQLAlchemy,CREATE USER, CREATE ROLE, EXPLAIN, ALTER DATABASE, REVOKE, NOLOCK, NOWAIT, EXISTS
, Unique constraint,.sql
- PostgreSQL:
pg_dump, pg_restore
,pgAdmin, pg_config, psql, pg_ctl, pg_isready, initdb
, Role, Schema, DBeaver, Navicat, DataGrip, OmniDB,Adminer
, docker-compose.xml PostgreSQL, PostgreSQL version, PostgreSQL logs,postgresql.conf
,pg_hba.conf, $HOME/.pg_service.conf
, Create database (PostgreSQL), Create user,createdb
,GRANT
,pg_stat
, PostgreSQL VACUUM, EXPLAIN,pg stat activity
, Autovacuum, ALTER DATABASE, PostgreSQL statistics collector, Shared buffers, EXPLAIN (PostgreSQL),EXPLAIN ANALYZE
, Bitmap scan,EXPLAIN VERBOSE
,EXPLAIN VERBOSE (PostgresSQL)
,WAL
,ALTER USER
,CREATE ROLE, CREATE USER
,\du
,show users
,\l
, The Statistics Collector, pganalyze,cron.schedule
, Master,pg_tables
, PostgreSQL replication,CREATE, SET
, TOAST, PgBouncer, Restore DB, Index, meta-commands, Table, foreign table, Schema, Sequence, Views, materialized view, Table Partitioning, monitoring, PostgreSQL System Administration Functions, PostgreSQL extension, privileges, logging, PGTune, PostgreSQL parameter tunning, PostgreSQL modules, pgbench, PostgreSQL users, catalogs
Advertising: