您好,欢迎来到伴沃教育。
搜索
您的当前位置:首页PostgreSQL Explain Basics

PostgreSQL Explain Basics

来源:伴沃教育

Different types of scan nodes

  • sequential scans
  • index scans
  • bitmap index scans

If the query requires joining, aggregation, sorting or other operation on the raw rows, there will be additional nodes above the scan nodes to perform these operations.

The output of EXPLAIN has one line for each node in the plan tree, showing the basic node type plus the cost estimates that the planner made for the execution of that plan node.

An example of a simple EXPLAIN output:

EXPLAIN SELECT * FROM tenk1;
Seq Scan on tenk1  (cost=0.00..458.00 rows=10000 width=244)

Content of the output:

  • sequential scan node
  • the first cost before '..' is estimated start-up cost.
  • estimated total cost
  • estimated number of rows returned
  • estimated average row width returned in bytes

Get number of pages and rows in a table

SELECT relpages, reltuples from pg_class where relanme = 'collection';
estimated_cost = disk_pages_read * seq_page_cost + rows_scanned * cpu_tuple_cost

Copyright © 2019- bangwoyixia.com 版权所有 湘ICP备2023022004号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务