HighGo Database中auto_explain模块的使用介绍
当我们想要跟踪大型应用中未优化的查询时,可使用auto_explain模块提供的一种自动的记录慢速语句执行计划的方法。这种方法可以让我们不必手动的运行EXPLAIN语句,所以使用这种方式是很有帮助的。1、使用方法要想使用这个模块,只需要把它加载到服务器中(只有数据库超级用户可以运行这条指令):highgo=# LOAD ‘auto_explain’;LOAD然后无论何时发生了意料之外的慢查询,我们
文档用途
当我们想要跟踪大型应用中未优化的查询时,可使用auto_explain模块提供的一种自动的记录慢速语句执行计划的方法。这种方法可以让我们不必手动的运行EXPLAIN语句,所以使用这种方式是很有帮助的。
详细信息
1、使用方法
要想使用这个模块,只需要把它加载到服务器中(只有数据库超级用户可以运行这条指令):
highgo=# LOAD ‘auto_explain’;
LOAD
然后无论何时发生了意料之外的慢查询,我们都可以进行追踪。
2、配置参数介绍及示例
配置参数控制着auto_explain的行为。需要注意的是,默认情况下的行为是什么也不做,所以如果想要得到相关结果,必须至少要设置auto_explain.log_min_duration这个参数。注意,只有数据库超级用户才能设置以下参数。
1)auto_explain.log_min_duration(integer)
这个参数指的是最小语句执行时间,单位是毫秒,设置之后语句计划就会被记录。例如,设置此参数的值为250毫秒,那么运行时间在250毫秒及以上的语句会被记录下来。默认值为-1,表示不记录任何计划。
highgo=# SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
count
-------
111
(1 row)
如果将此参数设置为0,表示记录所有的计划。
highgo=# SET auto_explain.log_min_duration = 0;
SET
highgo=# SET auto_explain.log_analyze = true;
SET
highgo=# SELECT count(*)
highgo-# FROM pg_class, pg_index
highgo-# WHERE oid = indrelid AND indisunique;
日志: 00000: duration: 0.935 ms plan:
Query Text: SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
Aggregate (cost=22.25..22.26 rows=1 width=0) (actual time=0.925..0.925 rows=1 loops=1)
-> Hash Join (cost=5.75..21.98 rows=111 width=0) (actual time=0.816..0.907 rows=111 loops=1)
Hash Cond: (pg_class.oid = pg_index.indrelid)
-> Index Only Scan using pg_class_oid_index on pg_class (cost=0.15..12.89 rows=316 width=4) (actual time=0.731..0.782 rows=317 loops=1)
Heap Fetches: 87
-> Hash (cost=4.22..4.22 rows=111 width=4) (actual time=0.046..0.046 rows=111 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 12kB
-> Seq Scan on pg_index (cost=0.00..4.22 rows=111 width=4) (actual time=0.006..0.023 rows=111 loops=1)
Filter: indisunique
Rows Removed by Filter: 11
count
-------
111
(1 row)
2)auto_explain.log_analyze(boolean)
设置这个参数使得当一个执行计划被记录时,会让EXPLAIN ANALYZE的结果,而不仅仅是EXPLAIN 的结果被打印出来。默认值为off。
highgo=# SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
日志: 00000: duration: 0.131 ms plan:
Query Text: SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
Aggregate (cost=22.25..22.26 rows=1 width=0)
-> Hash Join (cost=5.75..21.98 rows=111 width=0)
Hash Cond: (pg_class.oid = pg_index.indrelid)
-> Index Only Scan using pg_class_oid_index on pg_class (cost=0.15..12.89 rows=316 width=4)
-> Hash (cost=4.22..4.22 rows=111 width=4)
Buckets: 1024 Batches: 1 Memory Usage: 12kB
-> Seq Scan on pg_index (cost=0.00..4.22 rows=111 width=4)
Filter: indisunique
count
-------
111
(1 row)
将此参数设置为on之后,就能获得EXPLAIN ANALYZE的结果。
highgo=# SELECT count(*)
highgo-# FROM pg_class, pg_index
highgo-# WHERE oid = indrelid AND indisunique;
日志: 00000: duration: 0.935 ms plan:
Query Text: SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
Aggregate (cost=22.25..22.26 rows=1 width=0) (actual time=0.925..0.925 rows=1 loops=1)
-> Hash Join (cost=5.75..21.98 rows=111 width=0) (actual time=0.816..0.907 rows=111 loops=1)
Hash Cond: (pg_class.oid = pg_index.indrelid)
-> Index Only Scan using pg_class_oid_index on pg_class (cost=0.15..12.89 rows=316 width=4) (actual time=0.731..0.782 rows=317 loops=1)
Heap Fetches: 87
-> Hash (cost=4.22..4.22 rows=111 width=4) (actual time=0.046..0.046 rows=111 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 12kB
-> Seq Scan on pg_index (cost=0.00..4.22 rows=111 width=4) (actual time=0.006..0.023 rows=111 loops=1)
Filter: indisunique
Rows Removed by Filter: 11
count
-------
111
(1 row)
注意,将这个参数设置为on可能会对性能造成极大的不良影响,所以为了优化性能成本可以将它设置为off,代价是获得的信息会少一些。
3)auto_explain.log_buffers(boolean)
此参数控制着当一个执行计划被记录时,缓冲区用量统计信息是否被打印出来。这个参数只有当开启auto_explain.log_analyze后才有作用,默认为off。
将这个参数设置为on:
highgo=# SET auto_explain.log_buffers = on;
SET
highgo=# SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
日志: 00000: duration: 0.203 ms plan:
Query Text: SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
Aggregate (cost=22.25..22.26 rows=1 width=0) (actual time=0.197..0.197 rows=1 loops=1)
Buffers: shared hit=31
-> Hash Join (cost=5.75..21.98 rows=111 width=0) (actual time=0.059..0.188 rows=111 loops=1)
Hash Cond: (pg_class.oid = pg_index.indrelid)
Buffers: shared hit=31
-> Index Only Scan using pg_class_oid_index on pg_class (cost=0.15..12.89 rows=316 width=4) (actual time=0.013..0.060 rows=317 loops=1)
Heap Fetches: 87
Buffers: shared hit=28
-> Hash (cost=4.22..4.22 rows=111 width=4) (actual time=0.039..0.039 rows=111 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 12kB
Buffers: shared hit=3
-> Seq Scan on pg_index (cost=0.00..4.22 rows=111 width=4) (actual time=0.003..0.028 rows=111 loops=1)
Filter: indisunique
Rows Removed by Filter: 11
Buffers: shared hit=3
count
-------
111
(1 row)
从结果中看到,缓冲区信息被打印出来。
4)auto_explain.log_timing(boolean)
此参数控制着当一个执行计划被记录时,是否每个节点的时间信息都被打印出来。这个参数只有当开启auto_explain.log_analyze后才有作用,默认值为on。
将这个参数设置为on之后,时间信息就不会被打印出来:
highgo=# SET auto_explain.log_timing = off;
SET
highgo=# SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
日志: 00000: duration: 0.198 ms plan:
Query Text: SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
Aggregate (cost=22.25..22.26 rows=1 width=0) (actual rows=1 loops=1)
Buffers: shared hit=31
-> Hash Join (cost=5.75..21.98 rows=111 width=0) (actual rows=111 loops=1)
Hash Cond: (pg_class.oid = pg_index.indrelid)
Buffers: shared hit=31
-> Index Only Scan using pg_class_oid_index on pg_class (cost=0.15..12.89 rows=316 width=4) (actual rows=317 loops=1)
Heap Fetches: 87
Buffers: shared hit=28
-> Hash (cost=4.22..4.22 rows=111 width=4) (actual rows=111 loops=1)
Buckets: 1024 Batches: 1 Memory Usage: 12kB
Buffers: shared hit=3
-> Seq Scan on pg_index (cost=0.00..4.22 rows=111 width=4) (actual rows=111 loops=1)
Filter: indisunique
Rows Removed by Filter: 11
Buffers: shared hit=3
count
-------
111
(1 row)
需要注意的是,在有些系统中重复读取系统时钟的开销会显著地降低查询速率。所以如果我们只想得到实际的行数信息,而不是精确的时间信息的话,建议将此参数设置为off。
5)auto_explain.log_triggers(boolean)
此参数使得当一个执行计划被记录时,触发器的执行统计信息也会被包含进去。这个参数只有当开启auto_explain.log_analyze后才有作用,默认值为off。
6)auto_explain.log_verbose(boolean)
此参数控制着当执行计划被记录时,是否打印细节信息。默认值为off。
如果将此参数设置为on,就能打印出细节信息:
highgo=# SET auto_explain.log_verbose = on;
SET
highgo=# SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
日志: 00000: duration: 0.116 ms plan:
Query Text: SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
Aggregate (cost=22.25..22.26 rows=1 width=0) (actual rows=1 loops=1)
Output: count(*)
Buffers: shared hit=31
-> Hash Join (cost=5.75..21.98 rows=111 width=0) (actual rows=111 loops=1)
Hash Cond: (pg_class.oid = pg_index.indrelid)
Buffers: shared hit=31
-> Index Only Scan using pg_class_oid_index on pg_catalog.pg_class (cost=0.15..12.89 rows=316 width=4) (actual rows=317 loops=1)
Output: pg_class.oid
Heap Fetches: 87
Buffers: shared hit=28
-> Hash (cost=4.22..4.22 rows=111 width=4) (actual rows=111 loops=1)
Output: pg_index.indrelid
Buckets: 1024 Batches: 1 Memory Usage: 12kB
Buffers: shared hit=3
-> Seq Scan on pg_catalog.pg_index (cost=0.00..4.22 rows=111 width=4) (actual rows=111 loops=1)
Output: pg_index.indrelid
Filter: pg_index.indisunique
Rows Removed by Filter: 11
Buffers: shared hit=3
count
-------
111
(1 row)
7)auto_explain.log_format(enum)
设置这个参数可以选择要使用的EXPLAIN输出格式。默认为text格式,可选的格式有:text,xml,json 和yaml格式。
如果设置为xml格式:
highgo=# SET auto_explain.log_format = xml;
SET
highgo=# SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
日志: 00000: duration: 0.243 ms plan:
<explain xmlns="http://www.postgresql.org/2009/explain">
<Query-Text>SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;</Query-Text>
<Plan>
<Node-Type>Aggregate</Node-Type>
<Strategy>Plain</Strategy>
<Startup-Cost>22.25</Startup-Cost>
<Total-Cost>22.26</Total-Cost>
<Plan-Rows>1</Plan-Rows>
<Plan-Width>0</Plan-Width>
<Actual-Rows>1</Actual-Rows>
<Actual-Loops>1</Actual-Loops>
<Shared-Hit-Blocks>31</Shared-Hit-Blocks>
<Shared-Read-Blocks>0</Shared-Read-Blocks>
<Shared-Dirtied-Blocks>0</Shared-Dirtied-Blocks>
<Shared-Written-Blocks>0</Shared-Written-Blocks>
<Local-Hit-Blocks>0</Local-Hit-Blocks>
<Local-Read-Blocks>0</Local-Read-Blocks>
<Local-Dirtied-Blocks>0</Local-Dirtied-Blocks>
<Local-Written-Blocks>0</Local-Written-Blocks>
<Temp-Read-Blocks>0</Temp-Read-Blocks>
<Temp-Written-Blocks>0</Temp-Written-Blocks>
<Plans>
<Plan>
<Node-Type>Hash Join</Node-Type>
<Parent-Relationship>Outer</Parent-Relationship>
<Join-Type>Inner</Join-Type>
<Startup-Cost>5.75</Startup-Cost>
<Total-Cost>21.98</Total-Cost>
<Plan-Rows>111</Plan-Rows>
<Plan-Width>0</Plan-Width>
<Actual-Rows>111</Actual-Rows>
<Actual-Loops>1</Actual-Loops>
<Hash-Cond>(pg_class.oid = pg_index.indrelid)</Hash-Cond>
<Shared-Hit-Blocks>31</Shared-Hit-Blocks>
<Shared-Read-Blocks>0</Shared-Read-Blocks>
<Shared-Dirtied-Blocks>0</Shared-Dirtied-Blocks>
<Shared-Written-Blocks>0</Shared-Written-Blocks>
<Local-Hit-Blocks>0</Local-Hit-Blocks>
<Local-Read-Blocks>0</Local-Read-Blocks>
<Local-Dirtied-Blocks>0</Local-Dirtied-Blocks>
<Local-Written-Blocks>0</Local-Written-Blocks>
<Temp-Read-Blocks>0</Temp-Read-Blocks>
<Temp-Written-Blocks>0</Temp-Written-Blocks>
<Plans>
<Plan>
<Node-Type>Index Only Scan</Node-Type>
<Parent-Relationship>Outer</Parent-Relationship>
<Scan-Direction>Forward</Scan-Direction>
<Index-Name>pg_class_oid_index</Index-Name>
<Relation-Name>pg_class</Relation-Name>
<Alias>pg_class</Alias>
<Startup-Cost>0.15</Startup-Cost>
<Total-Cost>12.89</Total-Cost>
<Plan-Rows>316</Plan-Rows>
<Plan-Width>4</Plan-Width>
<Actual-Rows>317</Actual-Rows>
<Actual-Loops>1</Actual-Loops>
<Heap-Fetches>87</Heap-Fetches>
<Shared-Hit-Blocks>28</Shared-Hit-Blocks>
<Shared-Read-Blocks>0</Shared-Read-Blocks>
<Shared-Dirtied-Blocks>0</Shared-Dirtied-Blocks>
<Shared-Written-Blocks>0</Shared-Written-Blocks>
<Local-Hit-Blocks>0</Local-Hit-Blocks>
<Local-Read-Blocks>0</Local-Read-Blocks>
<Local-Dirtied-Blocks>0</Local-Dirtied-Blocks>
<Local-Written-Blocks>0</Local-Written-Blocks>
<Temp-Read-Blocks>0</Temp-Read-Blocks>
<Temp-Written-Blocks>0</Temp-Written-Blocks>
</Plan>
<Plan>
<Node-Type>Hash</Node-Type>
<Parent-Relationship>Inner</Parent-Relationship>
<Startup-Cost>4.22</Startup-Cost>
<Total-Cost>4.22</Total-Cost>
<Plan-Rows>111</Plan-Rows>
<Plan-Width>4</Plan-Width>
<Actual-Rows>111</Actual-Rows>
<Actual-Loops>1</Actual-Loops>
<Hash-Buckets>1024</Hash-Buckets>
<Original-Hash-Buckets>1024</Original-Hash-Buckets>
<Hash-Batches>1</Hash-Batches>
<Original-Hash-Batches>1</Original-Hash-Batches>
<Peak-Memory-Usage>12</Peak-Memory-Usage>
<Shared-Hit-Blocks>3</Shared-Hit-Blocks>
<Shared-Read-Blocks>0</Shared-Read-Blocks>
<Shared-Dirtied-Blocks>0</Shared-Dirtied-Blocks>
<Shared-Written-Blocks>0</Shared-Written-Blocks>
<Local-Hit-Blocks>0</Local-Hit-Blocks>
<Local-Read-Blocks>0</Local-Read-Blocks>
<Local-Dirtied-Blocks>0</Local-Dirtied-Blocks>
<Local-Written-Blocks>0</Local-Written-Blocks>
<Temp-Read-Blocks>0</Temp-Read-Blocks>
<Temp-Written-Blocks>0</Temp-Written-Blocks>
<Plans>
<Plan>
<Node-Type>Seq Scan</Node-Type>
<Parent-Relationship>Outer</Parent-Relationship>
<Relation-Name>pg_index</Relation-Name>
<Alias>pg_index</Alias>
<Startup-Cost>0.00</Startup-Cost>
<Total-Cost>4.22</Total-Cost>
<Plan-Rows>111</Plan-Rows>
<Plan-Width>4</Plan-Width>
<Actual-Rows>111</Actual-Rows>
<Actual-Loops>1</Actual-Loops>
<Filter>indisunique</Filter>
<Rows-Removed-by-Filter>11</Rows-Removed-by-Filter>
<Shared-Hit-Blocks>3</Shared-Hit-Blocks>
<Shared-Read-Blocks>0</Shared-Read-Blocks>
<Shared-Dirtied-Blocks>0</Shared-Dirtied-Blocks>
<Shared-Written-Blocks>0</Shared-Written-Blocks>
<Local-Hit-Blocks>0</Local-Hit-Blocks>
<Local-Read-Blocks>0</Local-Read-Blocks>
<Local-Dirtied-Blocks>0</Local-Dirtied-Blocks>
<Local-Written-Blocks>0</Local-Written-Blocks>
<Temp-Read-Blocks>0</Temp-Read-Blocks>
<Temp-Written-Blocks>0</Temp-Written-Blocks>
</Plan>
</Plans>
</Plan>
</Plans>
</Plan>
</Plans>
</Plan>
</explain>
count
-------
111
(1 row)
如果设置为json格式:
highgo=# SET auto_explain.log_format = json;
SET
highgo=# SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
日志: 00000: duration: 0.192 ms plan:
{
"Query Text": "SELECT count(*)\n FROM pg_class, pg_index\n WHERE oid = indrelid AND indisunique;",
"Plan": {
"Node Type": "Aggregate",
"Strategy": "Plain",
"Startup Cost": 22.25,
"Total Cost": 22.26,
"Plan Rows": 1,
"Plan Width": 0,
"Actual Rows": 1,
"Actual Loops": 1,
"Shared Hit Blocks": 31,
"Shared Read Blocks": 0,
"Shared Dirtied Blocks": 0,
"Shared Written Blocks": 0,
"Local Hit Blocks": 0,
"Local Read Blocks": 0,
"Local Dirtied Blocks": 0,
"Local Written Blocks": 0,
"Temp Read Blocks": 0,
"Temp Written Blocks": 0,
"Plans": [
{
"Node Type": "Hash Join",
"Parent Relationship": "Outer",
"Join Type": "Inner",
"Startup Cost": 5.75,
"Total Cost": 21.98,
"Plan Rows": 111,
"Plan Width": 0,
"Actual Rows": 111,
"Actual Loops": 1,
"Hash Cond": "(pg_class.oid = pg_index.indrelid)",
"Shared Hit Blocks": 31,
"Shared Read Blocks": 0,
"Shared Dirtied Blocks": 0,
"Shared Written Blocks": 0,
"Local Hit Blocks": 0,
"Local Read Blocks": 0,
"Local Dirtied Blocks": 0,
"Local Written Blocks": 0,
"Temp Read Blocks": 0,
"Temp Written Blocks": 0,
"Plans": [
{
"Node Type": "Index Only Scan",
"Parent Relationship": "Outer",
"Scan Direction": "Forward",
"Index Name": "pg_class_oid_index",
"Relation Name": "pg_class",
"Alias": "pg_class",
"Startup Cost": 0.15,
"Total Cost": 12.89,
"Plan Rows": 316,
"Plan Width": 4,
"Actual Rows": 317,
"Actual Loops": 1,
"Heap Fetches": 87,
"Shared Hit Blocks": 28,
"Shared Read Blocks": 0,
"Shared Dirtied Blocks": 0,
"Shared Written Blocks": 0,
"Local Hit Blocks": 0,
"Local Read Blocks": 0,
"Local Dirtied Blocks": 0,
"Local Written Blocks": 0,
"Temp Read Blocks": 0,
"Temp Written Blocks": 0
},
{
"Node Type": "Hash",
"Parent Relationship": "Inner",
"Startup Cost": 4.22,
"Total Cost": 4.22,
"Plan Rows": 111,
"Plan Width": 4,
"Actual Rows": 111,
"Actual Loops": 1,
"Hash Buckets": 1024,
"Original Hash Buckets": 1024,
"Hash Batches": 1,
"Original Hash Batches": 1,
"Peak Memory Usage": 12,
"Shared Hit Blocks": 3,
"Shared Read Blocks": 0,
"Shared Dirtied Blocks": 0,
"Shared Written Blocks": 0,
"Local Hit Blocks": 0,
"Local Read Blocks": 0,
"Local Dirtied Blocks": 0,
"Local Written Blocks": 0,
"Temp Read Blocks": 0,
"Temp Written Blocks": 0,
"Plans": [
{
"Node Type": "Seq Scan",
"Parent Relationship": "Outer",
"Relation Name": "pg_index",
"Alias": "pg_index",
"Startup Cost": 0.00,
"Total Cost": 4.22,
"Plan Rows": 111,
"Plan Width": 4,
"Actual Rows": 111,
"Actual Loops": 1,
"Filter": "indisunique",
"Rows Removed by Filter": 11,
"Shared Hit Blocks": 3,
"Shared Read Blocks": 0,
"Shared Dirtied Blocks": 0,
"Shared Written Blocks": 0,
"Local Hit Blocks": 0,
"Local Read Blocks": 0,
"Local Dirtied Blocks": 0,
"Local Written Blocks": 0,
"Temp Read Blocks": 0,
"Temp Written Blocks": 0
}
]
}
]
}
]
}
}
count
-------
111
(1 row)
如果设置为yaml格式:
highgo=# SET auto_explain.log_format = yaml;
SET
highgo=# SELECT count(*)
FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique;
日志: 00000: duration: 0.123 ms plan:
Query Text: "SELECT count(*)\n FROM pg_class, pg_index\n WHERE oid = indrelid AND indisunique;"
Plan:
Node Type: "Aggregate"
Strategy: "Plain"
Startup Cost: 22.25
Total Cost: 22.26
Plan Rows: 1
Plan Width: 0
Actual Rows: 1
Actual Loops: 1
Shared Hit Blocks: 31
Shared Read Blocks: 0
Shared Dirtied Blocks: 0
Shared Written Blocks: 0
Local Hit Blocks: 0
Local Read Blocks: 0
Local Dirtied Blocks: 0
Local Written Blocks: 0
Temp Read Blocks: 0
Temp Written Blocks: 0
Plans:
- Node Type: "Hash Join"
Parent Relationship: "Outer"
Join Type: "Inner"
Startup Cost: 5.75
Total Cost: 21.98
Plan Rows: 111
Plan Width: 0
Actual Rows: 111
Actual Loops: 1
Hash Cond: "(pg_class.oid = pg_index.indrelid)"
Shared Hit Blocks: 31
Shared Read Blocks: 0
Shared Dirtied Blocks: 0
Shared Written Blocks: 0
Local Hit Blocks: 0
Local Read Blocks: 0
Local Dirtied Blocks: 0
Local Written Blocks: 0
Temp Read Blocks: 0
Temp Written Blocks: 0
Plans:
- Node Type: "Index Only Scan"
Parent Relationship: "Outer"
Scan Direction: "Forward"
Index Name: "pg_class_oid_index"
Relation Name: "pg_class"
Alias: "pg_class"
Startup Cost: 0.15
Total Cost: 12.89
Plan Rows: 316
Plan Width: 4
Actual Rows: 317
Actual Loops: 1
Heap Fetches: 87
Shared Hit Blocks: 28
Shared Read Blocks: 0
Shared Dirtied Blocks: 0
Shared Written Blocks: 0
Local Hit Blocks: 0
Local Read Blocks: 0
Local Dirtied Blocks: 0
Local Written Blocks: 0
Temp Read Blocks: 0
Temp Written Blocks: 0
- Node Type: "Hash"
Parent Relationship: "Inner"
Startup Cost: 4.22
Total Cost: 4.22
Plan Rows: 111
Plan Width: 4
Actual Rows: 111
Actual Loops: 1
Hash Buckets: 1024
Original Hash Buckets: 1024
Hash Batches: 1
Original Hash Batches: 1
Peak Memory Usage: 12
Shared Hit Blocks: 3
Shared Read Blocks: 0
Shared Dirtied Blocks: 0
Shared Written Blocks: 0
Local Hit Blocks: 0
Local Read Blocks: 0
Local Dirtied Blocks: 0
Local Written Blocks: 0
Temp Read Blocks: 0
Temp Written Blocks: 0
Plans:
- Node Type: "Seq Scan"
Parent Relationship: "Outer"
Relation Name: "pg_index"
Alias: "pg_index"
Startup Cost: 0.00
Total Cost: 4.22
Plan Rows: 111
Plan Width: 4
Actual Rows: 111
Actual Loops: 1
Filter: "indisunique"
Rows Removed by Filter: 11
Shared Hit Blocks: 3
Shared Read Blocks: 0
Shared Dirtied Blocks: 0
Shared Written Blocks: 0
Local Hit Blocks: 0
Local Read Blocks: 0
Local Dirtied Blocks: 0
Local Written Blocks: 0
Temp Read Blocks: 0
Temp Written Blocks: 0
count
-------
111
(1 row)
8)auto_explain.log_nested_statements
设置此参数可以让嵌套语句被记录下来。默认值为off,表示只有顶层查询会被记录。
9)auto_explain.sample_rate使auto_explain
设置此参数可以使auto_explain只解释每个会话中的一部分语句。默认值为1,表示解释所有的查询。
更多推荐



所有评论(0)