12 Beta3 PostgreSQL,创建包含8192个子分区的分区表,执行查询语句,在分区键上排序,出的错。
数据库版本:
<前>
<代码>(本地):5432 pg12@testdb=#选择版本();
版本
--------------------------------------------------------------------------------------------
PostgreSQL 12 beta3 x86_64-pc-linux-gnu,海湾合作委员会(gcc)编制4.8.5 20150623 (Red Hat 4。
-16 - 8.5),64位
(1行)
时间:9.511毫秒
代码>
数据表结构
<前> <代码>(本地):5432 pg12@testdb=# \ d t_hash_manypartitions 分区表“public.t_hash_manypartitions” 专栏| |类型排序| Nullable |违约 --------+-----------------------+-----------+----------+--------- c1整数| | | | c2 |字符不同(40)| | | c3 |字符不同(40)| | | 分区键:哈希(c2) 分区数量:8191(使用\ d +列表。) 代码>只有1行数据
<前> <代码>(本地):5432 pg12@testdb=#插入t_hash_manypartitions (c1, c2, c3)值(0 ' c2-0 ' ' c3-0 '); 插入0 1 时间:14.038毫秒 (本地):5432 pg12@testdb=# select * from t_hash_manypartitions; c1 | c2 | c3 - - - - - + - - - - - - - - - - - - 0 | c2-0 | c3-0 (1行) 时间:917.996毫秒 (本地):5432 pg12@testdb=# 代码>虽然只有1行数据,但全表扫描仍然很慢,接近1 s,而普通表仅几毫秒。
<前> <代码>(本地):5432 pg12@testdb=# select * from t_hash_manypartitions; c1 | c2 | c3 - - - - - + - - - - - - - - - - - - 0 | c2-0 | c3-0 (1行) 时间:898.615毫秒 (本地):5432 pg12@testdb=# select * from t_hash_manypartitions; c1 | c2 | c3 - - - - - + - - - - - - - - - - - - 0 | c2-0 | c3-0 (1行) 时间:898.783毫秒 (本地):5432 pg12@testdb=# 代码>执行查询,在分区键c2上排序
<前> <代码>(本地):5432 pg12@testdb=# select * from t_hash_manypartitions c2秩序; 错误:共享内存 提示:您可能需要增加max_locks_per_transaction。 背景:并行工作 时间:2420.971(00:02.421)女士 (本地):5432 pg12@testdb=# 代码>提示共享内存,内存溢出
<前> <代码>(本地):5432 pg12@testdb=#改变系统设置max_locks_per_transaction=128; 改变系统 时间:7.705毫秒 (本地):5432 pg12@testdb=# select * from t_hash_manypartitions c2秩序; 错误:共享内存 提示:您可能需要增加max_locks_per_transaction。 背景:并行工作 时间:1988.893(00:01.989)女士 (本地):5432 pg12@testdb=#改变系统设置max_locks_per_transaction=512; 改变系统 时间:13.137毫秒 (本地):5432 pg12@testdb=# select * from t_hash_manypartitions c2秩序; 错误:共享内存 提示:您可能需要增加max_locks_per_transaction。 背景:并行工作 时间:1968.974(00:01.969)女士 (本地):5432 pg12@testdb=#改变系统设置max_locks_per_transaction=8192; 改变系统 时间:4.060毫秒 (本地):5432 pg12@testdb=# select * from t_hash_manypartitions c2秩序; 错误:共享内存 提示:您可能需要增加max_locks_per_transaction。 背景:并行工作 时间:1985.106(00:01.985)女士 (本地):5432 pg12@testdb=#改变系统设置max_locks_per_transaction=16384; 改变系统 时间:7.791毫秒 (本地):5432 pg12@testdb=# select * from t_hash_manypartitions c2秩序; 错误:共享内存 提示:您可能需要增加max_locks_per_transaction。 背景:并行工作 时间:1953.134(00:01.953)女士 (本地):5432 pg12@testdb=# 代码>可以看的到,增大该参数值至16384年,仍然报的错。
<>强修改此参数需重启数据库,重启数据库后重新执行即可强>
查看执行计划,PG在每个分区上执行并行扫描,然后使用平行附加合并结果集,然后再执行排序。
<前>
<代码>(本地):5432 pg12@testdb=#解释由c2 select * from t_hash_manypartitions秩序;
查询计划
--------------------------------------------------------------------------------------------
收集合并(成本=455382.87 . .宽度734442.42行=2391772=200)
工人计划:2
→排序(成本=454382.84 . .宽度457372.56行=1195886=200)
排序关键字:t_hash_manypartitions_1.c2
→平行Append(成本=0.00 . .宽度104753.25行=1195886=200)
→平行Seq扫描t_hash_manypartitions_1(成本=0.00=206 . . 12.06行
宽度=200)
→平行Seq扫描t_hash_manypartitions_2(成本=0.00=206 . . 12.06行
宽度=200)
→平行Seq扫描t_hash_manypartitions_3(成本=0.00=206 . . 12.06行
宽度=200)
→平行Seq扫描t_hash_manypartitions_4(成本=0.00=206 . . 12.06行
宽度=200)
→平行Seq扫描t_hash_manypartitions_5(成本=0.00=206 . . 12.06行
宽度=200)
→平行Seq扫描t_hash_manypartitions_6(成本=0.00=206 . . 12.06行
宽度=200)
→平行Seq扫描t_hash_manypartitions_7(成本=0.00=206 . . 12.06行
宽度=200)
→平行Seq扫描t_hash_manypartitions_8(成本=0.00=206 . . 12.06行
宽度=200)
→平行Seq扫描t_hash_manypartitions_9(成本=0.00=206 . . 12.06行
宽度=200)
→平行Seq扫描t_hash_manypartitions_10(成本=0.00=206 . . 12.06行
宽度=200)
→平行Seq扫描t_hash_manypartitions_11(成本=0.00=206 . . 12.06行
宽度=200)
→平行Seq扫描t_hash_manypartitions_12(成本=0.00=206 . . 12.06行
宽度=200)
→平行Seq扫描t_hash_manypartitions_13(成本=0.00=206 . . 12.06行
宽度=200)
→平行Seq扫描t_hash_manypartitions_14(成本=0.00=206 . . 12.06行
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null
null