Postgres-XL是基于PostgreSQL的一个分布式数据库。

  相比于PostgreSQL,XL的表的数据是可以分布到不同的datanode上的,对存在于不同的datanode上的数据进行处理,目前还存在很多限制。当然可能在以后的新版本中,会突破这些限制。

  下面针对postgres-xl-10r1版本进行测试,看看目前还存在哪些限制。

1. 分布建不能更新

 select * from test2;
id | name
----+------
|
|
|
|
|
( rows) postgres=# update test2 set name='b' where id=;
UPDATE postgres=# update test2 set id= where name='';
-- ::49.533 CST [] ERROR: could not plan this distributed update
-- ::49.533 CST [] DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
-- ::49.533 CST [] STATEMENT: update test2 set id= where name='';
ERROR: could not plan this distributed update
DETAIL: correlated UPDATE or updating distribution column currently not supported in Postgres-XL. postgres=# select * from test2;
id | name
----+------
|
|
| b
|
|
( rows)

2. 复杂查询

  在PostgreSQL,表数据只放在一台pc上,当两个表关联查询时,可以直接获取到表数据进行join。但是在Postgres-XL中,表数据是分布在不同的datanode上,datanode又可能分布在不同的pc上;这时候两个表进行关联查询需要从不同的datanode之间进行,如果是多个表进行关联查询,情况更加复杂了。

2.1 非分布键作为条件限制

 postgres=# select * from test1,test2;
id | name | id | name
----+------+----+------
| a | |
.
.
.
| b | | b
.
.
.
| d | |
( rows) postgres=# select * from test1,test2 where test1.name='b' and test2.name='b';
id | name | id | name
----+------+----+------
| b | | b
( row) postgres=# select * from test1,test2 where test1.name=test2.name;
-- ::08.939 CST [] ERROR: cannot wait on a latch owned by another process
-- ::08.939 CST [] LOG: server process (PID ) was terminated by signal : Segmentation fault
-- ::08.939 CST [] DETAIL: Failed process was running: Remote Subplan
-- ::08.939 CST [] LOG: terminating any other active server processes
-- ::08.940 CST [] WARNING: terminating connection because of crash of another server process
.
.
.

  当where条件中直接判断两个表字段是否相等时,报错。多次尝试后,还出现过其他错误(例如:“ERROR:  Couldn't resolve SQueue race condition after 10 tries”),有时候也能执行成功,证明这一查询还是存在很大的问题。

2.2 非亲和表的限制

  亲和表,即两张表的分布类型和分布键都一致,称这两张表为亲和表。

表test3和表test4都是以id列作为分布键、分布类型为Modulo,test3和test4是亲和表。

 postgres=# \d+ test3
Table "public.test3"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+-----------------------------------+----------+--------------+-------------
id | integer | | not null | nextval('test3_id_seq'::regclass) | plain | |
name | text | | | | extended | |
Indexes:
"test3_pkey" PRIMARY KEY, btree (id)
Distribute By: MODULO(id)
Location Nodes: ALL DATANODES postgres=# \d+ test4
Table "public.test4"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+---------+--------------+-------------
id | integer | | | | plain | |
Distribute By: MODULO(id)
Location Nodes: ALL DATANODES postgres=# select * from test3 order by id;
id | name
----+------
| a
| b
| cc
| dd
| ee
| ff
( rows) postgres=# select * from test4 order by id;
id
---- ( rows) postgres=# select * from test4 a inner join test3 b on a.id=b.id order by a.id;
id | id | name
----+----+------
| | a
| | b
| | dd
| | ff
( rows)

  下面是非亲和表test2与test4的内连接查询。结果是不正确的,而且有时执行查询会报错。

 postgres=# \d+ test2
Table "public.test2"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+---------+-----------+----------+---------+----------+--------------+-------------
id | integer | | not null | | plain | |
name | text | | | | extended | |
Indexes:
"test2_pkey" PRIMARY KEY, btree (id)
Distribute By: HASH(id)
Location Nodes: ALL DATANODES postgres=# select * from test2 order by id;
id | name
-----+------
|
| b
|
|
|
|
|
|
( rows) postgres=# select * from test2 a inner join test4 b on a.id=b.id order by a.id;
-- ::19.389 CST [] WARNING: Unexpected data on connection, cleaning.
id | name | id
----+------+----
| b |
| |
| |
( rows)

  同样,outer join也存在一样的问题,不支持非亲和表的关联查询。但是,非亲和表可以进行cross join关联查询(没有where条件)。

2.3 子查询限制

  子查询也受到非亲和表的限制,与2.2的情况基本一致,就不再去说明了。

  特殊说明:2.2和2.3中提到非亲和表的限制问题,我后来增加了一个节点datanode3。结果再进行非亲和表关联时都正常了,没有再报错(上面提到有两个报错),查出来的结果也完全正确。这什么情况,郁闷。后来再尝试把节点datanode3从集群中删掉,也没有重现分亲和表限制的问题。

3. 支持特性

  这里顺便提一下Postgres-XL支持的特性吧,方便记录一下在测试过程中测试到的项。

  • CTE(通用表表达式),支持,但是里面的sql也受到上面提到的限制问题;
  • Windows function,支持,同上;
  • 集合操作,支持,同上;
  • 非分片列count(distinct),支持;
  • 支持跨分片更新;
  • 支持跨分片事务;

总结

  这次针对Postgres-XL去调研它目前存在的限制,主要还是在查询上限制比较大。在测试过程中,没有对所有的sql功能进行测试,也没有太深入去研究。

  如果在以上说明存在的限制(或者支持特性)有不符合pgxl实际情况的,可能是我个人的错误,欢迎大牛指出。

  希望Postgres-XL在以后的版本中,能把这些限制给解决掉,越做越完善。

最新文章

  1. [R语言]R语言计算unix timestamp的坑
  2. android服务里生成通知点击后返回正在运行的程序和当前的Activity
  3. VR(虚拟现实)开发资源汇总
  4. JavaScript的函数重载
  5. Android adb 命令使用总结
  6. 一段OpenGL的简单代码
  7. 你了解System.out.println()的真正含义吗?
  8. UVa11925 Generating Premutations
  9. EffectiveC#11--选择foreach循环
  10. 在CentOS7上部署OpenStack 步骤详解
  11. Redis 设计与实现 (二)--数据库
  12. Linux -- nginx
  13. ssh 多次登录禁用账号
  14. [转]python中pandas库中DataFrame对行和列的操作使用方法
  15. cookie&session的Q&A故事[原理篇]
  16. 3.网络编程-tcp的服务器简单实现
  17. ping主机不通邮件报警
  18. 【Think in java读书笔记】序列化
  19. python 变量名的规范
  20. nodejs学习笔记<七> 路由

热门文章

  1. 微信小程序采坑之上拉触底加载更多和下拉刷新
  2. js 获取两个日期相差的天数--自定义方法
  3. UVaLive6443(线段树)
  4. windows 2008 r2或win7安装SP1补丁,安装sqlserver 2012
  5. RabbitMQ使用教程(二)RabbitMQ用户管理,角色管理及权限设置
  6. 渣渣菜鸡的 ElasticSearch 源码解析 —— 启动流程(下)
  7. Unity使用 转载
  8. SlickEdit 18.0 版本发布 同时更新破解文件
  9. 解决Mysql导入大数据出现gone away的问题
  10. xwork-conversion.properties 目前没有解决方案