【发布时间】:2015-10-07 08:45:01
【问题描述】:
阅读此article 我发现了以下示例:
EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM foo ORDER BY c1;
查询的计划是这样的:
Sort (cost=172682.84..175182.84 rows=1000000 width=37) (actual time=584.215..681.531 rows=1000000 loops=1)
Sort Key: c1
Sort Method: external sort Disk: 45928kB
Buffers: shared hit=3197 read=5137, temp read=5741 written=5741
-> Seq Scan on foo (cost=0.00..18334.00 rows=1000000 width=37) (actual time=0.036..91.914 rows=1000000 loops=1)
Buffers: shared hit=3197 read=5137
Total runtime: 711.195 ms
As known, 外部排序是一系列算法。这是否意味着PostgreSQL 确实external merge sort?如果是这样,我怎样才能得到一些细节,例如批次数量及其大小。有没有可能?
【问题讨论】:
-
你需要查看源代码。
-
@a_horse_with_no_name 这是唯一的方法吗? PosgtrSQL 不提供有关它使用的算法的详细信息,是吗?
-
它不能比实际实现更详细了。
标签: sql postgresql sql-order-by