前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >[PostgreSQL] - explain SQL分析介绍

[PostgreSQL] - explain SQL分析介绍

作者头像
夹胡碰
发布2022-07-30 11:22:14
6600
发布2022-07-30 11:22:14
举报
文章被收录于专栏:程序猿~程序猿~

一、图形化在线分析工具

https://explain.dalibo.com/

二、执行分析语句

代码语言:javascript
复制
EXPLAIN (ANALYZE, COSTS, VERBOSE, BUFFERS, FORMAT JSON)
select * from ...

生成分析JSON之后,填入图形化分析页面,进行分析。

三、分析样例

1、走索引 - Index Scan Node

表示先走二级索引,再走一级索引找到数据

finds relevant records based on an Index. Index Scans perform 2 read operations: one to read the index and another to read the actual value from the table.

2、顺序扫描 - Seq Scan Node

finds relevant records by sequentially scanning the input record set. When reading from a table, Seq Scans (unlike Index Scans) perform a single read operation (only the table is read).

3、缓存 - shared

  • Hit - 命中
  • Read - 读磁盘
  • Dirtied - 脏页(脏页包含在Hit中)

4、循环匹配 - Nested Loop

join数据,将两个结果集进行拼接

merges two record sets by looping through every record in the first set and trying to find a match in the second set. All matching records are returned.

遍历模式

索引模式

5、聚合 - Aggregate

group by 操作

groups records together based on a GROUP BY or aggregate function (like sum()).

6、排序 - Sort

order by 操作

sorts a record set based on the specified sort key.

7、数量限制 - limit

returns a specified number of rows from a record set.

8、with as 临时表 - Common table expressions - CTE

performs a sequential scan of Common Table Expression (CTE) query results. Note that results of a CTE are materialized (calculated and temporarily stored). 对公共表表达式(CTE)查询结果执行顺序扫描。注意,CTE的结果是具体化的(计算并临时存储)。

9、其他操作

  • WindowAgg
  • Subquery Scan

10、其他join模式图解

  • Hash Join
  • Merge Join
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2022-07-28,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 一、图形化在线分析工具
  • 二、执行分析语句
  • 三、分析样例
    • 1、走索引 - Index Scan Node
      • 2、顺序扫描 - Seq Scan Node
        • 3、缓存 - shared
          • 4、循环匹配 - Nested Loop
            • 5、聚合 - Aggregate
              • 6、排序 - Sort
                • 7、数量限制 - limit
                  • 8、with as 临时表 - Common table expressions - CTE
                    • 9、其他操作
                      • 10、其他join模式图解
                      领券
                      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档