I hava below two statement sql:

0. not in subquery

select a.schemaname, pg_size_pretty(pg_total_relation_size(a.schemaname||'.'||a.tablename)) from pg_tables a where a.tablename not in (select b.tablename from t b);

1. in subquery

select a.schemaname, pg_size_pretty(pg_total_relation_size(a.schemaname||'.'||a.tablename)) from pg_tables a where a.tablename in (select b.tablename from t b);



The [0. not in subquery] can't work well, it's occur error:

ERROR: query plan with multiple segworker groups is not supported (cdbdisp.c:500)

HINT: likely caused by a function that reads or modifies data in a distributed table

CONTEXT: SQL statement "select sum(pg_total_relation_size('information_schema.sql_languages'))::int8 from gp_dist_random('gp_id');"



The [1. in subquery] work well.



Detailed below test:

gtlions=# select version();
version
------------------------------------------------------------------------------------------------------------------------------------------------------
PostgreSQL 8.2.15 (Greenplum Database 4.2.7.3 build 1) on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 4.4.2 compiled on May 7 2014 14:31:08
(1 row) gtlions=# select a.schemaname, pg_size_pretty(pg_total_relation_size(a.schemaname||'.'||a.tablename)) from pg_tables a where a.tablename not in (select b.tablename from t b);
ERROR: query plan with multiple segworker groups is not supported (cdbdisp.c:500)
HINT: likely caused by a function that reads or modifies data in a distributed table
CONTEXT: SQL statement "select sum(pg_total_relation_size('information_schema.sql_languages'))::int8 from gp_dist_random('gp_id');"
gtlions=# explain select a.schemaname, pg_size_pretty(pg_total_relation_size(a.schemaname||'.'||a.tablename)) from pg_tables a where a.tablename not in (select b.tablename from t b);
QUERY PLAN
-----------------------------------------------------------------------------------------------
Hash Left Anti Semi Join (cost=568.98..235912.69 rows=676396 width=128)
Hash Cond: c.relname = "NotIn_SUBQUERY".tablename::name
-> Hash Left Join (cost=395.97..223194.68 rows=676419 width=128)
Hash Cond: c.relnamespace = n.oid
-> Hash Left Join (cost=2.62..112777.67 rows=676419 width=68)
Hash Cond: c.reltablespace = t.oid
-> Seq Scan on pg_class c (cost=0.00..2751.39 rows=676419 width=72)
Filter: relkind = 'r'::"char" AND relname IS NOT NULL
-> Hash (cost=1.02..1.02 rows=2 width=4)
-> Seq Scan on pg_tablespace t (cost=0.00..1.02 rows=128 width=4)
-> Hash (cost=365.35..365.35 rows=35 width=68)
-> Seq Scan on pg_namespace n (cost=0.00..365.35 rows=2240 width=68)
-> Hash (cost=106.61..106.61 rows=83 width=274)
-> Gather Motion 64:1 (slice1; segments: 64) (cost=0.00..106.61 rows=83 width=274)
-> Subquery Scan "NotIn_SUBQUERY" (cost=0.00..52.66 rows=2 width=274)
-> Seq Scan on t b (cost=0.00..51.83 rows=2 width=24)
(16 rows) gtlions=# select a.schemaname, pg_size_pretty(pg_total_relation_size(a.schemaname||'.'||a.tablename)) from pg_tables a where a.tablename in (select b.tablename from t b);
schemaname | size-1
-------------+---------
public | 32 kB
public | 32 kB
......
......
public | 96 kB
gtlions=# explain select a.schemaname, pg_size_pretty(pg_total_relation_size(a.schemaname||'.'||a.tablename)) from pg_tables a where a.tablename in (select b.tablename from t b);
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------
Gather Motion 64:1 (slice7; segments: 64) (cost=445.41..10096.03 rows=1 width=128)
-> Hash Left Join (cost=445.41..10096.03 rows=1 width=128)
Hash Cond: c.reltablespace = t.oid
-> Redistribute Motion 64:64 (slice5; segments: 64) (cost=443.06..10092.81 rows=1 width=132)
Hash Key: c.reltablespace
-> Hash Left Join (cost=443.06..10092.22 rows=1 width=132)
Hash Cond: c.relnamespace = n.oid
-> Redistribute Motion 64:64 (slice3; segments: 64) (cost=54.53..9703.24 rows=1 width=72)
Hash Key: c.relnamespace
-> Hash EXISTS Join (cost=54.53..9702.65 rows=1 width=72)
Hash Cond: c.relname = b.tablename::name
-> Redistribute Motion 1:64 (slice1) (cost=0.00..9621.26 rows=10570 width=72)
Hash Key: c.relname
-> Seq Scan on pg_class c (cost=0.00..2751.39 rows=676419 width=72)
Filter: relkind = 'r'::"char"
-> Hash (cost=53.49..53.49 rows=2 width=24)
-> Redistribute Motion 64:64 (slice2; segments: 64) (cost=0.00..53.49 rows=2 width=24)
Hash Key: b.tablename::name
-> Seq Scan on t b (cost=0.00..51.83 rows=2 width=24)
-> Hash (cost=388.10..388.10 rows=1 width=68)
-> Redistribute Motion 1:64 (slice4) (cost=0.00..388.10 rows=35 width=68)
Hash Key: n.oid
-> Seq Scan on pg_namespace n (cost=0.00..365.35 rows=2240 width=68)
-> Hash (cost=2.32..2.32 rows=1 width=4)
-> Redistribute Motion 1:64 (slice6) (cost=0.00..2.32 rows=2 width=4)
Hash Key: t.oid
-> Seq Scan on pg_tablespace t (cost=0.00..1.02 rows=128 width=4)
(27 rows)

该问题应该是个Bug,等一下TSE鉴于Fix或不Fix而只是等待,直到下一个版本升级.

-EOF-

版权声明:本文博主原创文章,博客,未经同意不得转载。

最新文章

  1. 转ASP.NET1.1请求队列限制
  2. java学习之 反射
  3. mysql 插入/更新数据
  4. NFS和mount常用参数详解
  5. Unity脚本生命周期
  6. 完成端口(IOCP)怎么判断某个连接是否断开
  7. Linq扩展方法之All 、Any
  8. NAND FLASH特性说明
  9. Atom 编辑器试用
  10. 微软project文件mpp解析
  11. Python迭代器、生成器
  12. Linux安装Tomcat-Nginx-FastDFS-Redis-Solr-集群——【第六集之补充:文本编辑器vi/vim】
  13. 吴恩达机器学习笔记53-高斯分布的算法(Algorithm of Gaussian Distribution)
  14. word20161228
  15. mysq
  16. zookeeper命令行客户端
  17. 不存数据库生成验证码(totp算法)
  18. js学习(一)-动态添加、修改、删除对象的属性和方法
  19. Object C学习笔记10-静态方法和静态属性
  20. wireshark udp 序列号 User Datagram Protocol UDP

热门文章

  1. 【转载】Using the Web Service Callbacks in the .NET Application
  2. 第 3 章 单例模式【Singleton Pattern】
  3. 矩阵分解(rank decomposition)文章代码汇总
  4. Win7系统Matlab2013a安装.m文件不自动关联到MATLAB.exe解决方法
  5. 构建简单的 C++ 服务组件,第 1 部分: 服务组件体系结构 C++ API 简介
  6. 一个简单的DDraw应用程序2
  7. 使用AspNetPager与GridView完成分页
  8. CKFinder 2.4 ASP.NET 破解
  9. Java序列化技术
  10. js前台与后台数据交互-前台调后台