Postgres-XL的限制


  Postgres-XL是基於PostgreSQL的一個分布式數據庫。

  相比於PostgreSQL,XL的表的數據是可以分布到不同的datanode上的,對存在於不同的datanode上的數據進行處理,目前還存在很多限制。當然可能在以后的新版本中,會突破這些限制。

  下面針對postgres-xl-10r1版本進行測試,看看目前還存在哪些限制。

1. 分布建不能更新

 1 select * from test2;
 2  id | name 
 3 ----+------
 4   1 | 1
 5   2 | 2
 6   5 | 5
 7   3 | 3
 8   4 | 4
 9 (5 rows)
10 
11 postgres=# update test2 set name='b' where id=2;                 
12 UPDATE 1
13 
14 postgres=# update test2 set id=5 where name='5';         
15 2018-11-07 18:13:49.533 CST [1831] ERROR:  could not plan this distributed update
16 2018-11-07 18:13:49.533 CST [1831] DETAIL:  correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
17 2018-11-07 18:13:49.533 CST [1831] STATEMENT:  update test2 set id=5 where name='5';
18 ERROR:  could not plan this distributed update
19 DETAIL:  correlated UPDATE or updating distribution column currently not supported in Postgres-XL.
20 
21 postgres=# select * from test2;
22  id | name 
23 ----+------
24   1 | 1
25   5 | 5
26   2 | b
27   3 | 3
28   4 | 4
29 (5 rows)

 

2. 復雜查詢

  在PostgreSQL,表數據只放在一台pc上,當兩個表關聯查詢時,可以直接獲取到表數據進行join。但是在Postgres-XL中,表數據是分布在不同的datanode上,datanode又可能分布在不同的pc上;這時候兩個表進行關聯查詢需要從不同的datanode之間進行,如果是多個表進行關聯查詢,情況更加復雜了。

2.1 非分布鍵作為條件限制

 1 postgres=# select * from test1,test2;                                        
 2  id | name | id | name 
 3 ----+------+----+------
 4   1 | a    |  1 | 1
 5           .
 6           .
 7           .
 8   2 | b    |  2 | b
 9           .
10           .
11           .
12   4 | d    |  4 | 4
13 (40 rows)   
14 
15 postgres=# select * from test1,test2 where test1.name='b' and test2.name='b';
16  id | name | id | name 
17 ----+------+----+------
18   2 | b    |  2 | b
19 (1 row)
20 
21 postgres=# select * from test1,test2 where test1.name=test2.name;            
22 2018-11-08 11:08:08.939 CST [1510] ERROR: cannot wait on a latch owned by another process 23 2018-11-08 11:08:08.939 CST [1405] LOG:  server process (PID 1510) was terminated by signal 11: Segmentation fault
24 2018-11-08 11:08:08.939 CST [1405] DETAIL:  Failed process was running: Remote Subplan
25 2018-11-08 11:08:08.939 CST [1405] LOG:  terminating any other active server processes
26 2018-11-08 11:08:08.940 CST [1436] WARNING:  terminating connection because of crash of another server process
27           .
28           .
29           .

  當where條件中直接判斷兩個表字段是否相等時,報錯。多次嘗試后,還出現過其他錯誤(例如:“ERROR:  Couldn't resolve SQueue race condition after 10 tries”),有時候也能執行成功,證明這一查詢還是存在很大的問題。

 

2.2 非親和表的限制

  親和表,即兩張表的分布類型和分布鍵都一致,稱這兩張表為親和表。

 表test3和表test4都是以id列作為分布鍵、分布類型為Modulo,test3和test4是親和表。

 1 postgres=# \d+ test3
 2                                                 Table "public.test3"
 3  Column |  Type   | Collation | Nullable |              Default              | Storage  | Stats target | Description 
 4 --------+---------+-----------+----------+-----------------------------------+----------+--------------+-------------
 5  id     | integer |           | not null | nextval('test3_id_seq'::regclass) | plain    |              | 
 6  name   | text    |           |          |                                   | extended |              | 
 7 Indexes:
 8     "test3_pkey" PRIMARY KEY, btree (id)
 9 Distribute By: MODULO(id)
10 Location Nodes: ALL DATANODES
11 
12 postgres=# \d+ test4
13                                    Table "public.test4"
14  Column |  Type   | Collation | Nullable | Default | Storage | Stats target | Description 
15 --------+---------+-----------+----------+---------+---------+--------------+-------------
16  id     | integer |           |          |         | plain   |              | 
17 Distribute By: MODULO(id)
18 Location Nodes: ALL DATANODES
19 
20 postgres=# select * from test3 order by id;
21  id | name 
22 ----+------
23   1 | a
24   2 | b
25   3 | cc
26   4 | dd
27   5 | ee
28   6 | ff
29 (6 rows)
30 
31 postgres=# select * from test4 order by id; 
32  id 
33 ----
34   1
35   2
36   4
37   6
38   8
39 (5 rows)
40 
41 postgres=# select * from test4 a inner join test3 b on a.id=b.id order by a.id;
42  id | id | name 
43 ----+----+------
44   1 |  1 | a
45   2 |  2 | b
46   4 |  4 | dd
47   6 |  6 | ff
48 (4 rows)

 

   下面是非親和表test2與test4的內連接查詢。結果是不正確的,而且有時執行查詢會報錯。

 1 postgres=# \d+ test2
 2                                    Table "public.test2"
 3  Column |  Type   | Collation | Nullable | Default | Storage  | Stats target | Description 
 4 --------+---------+-----------+----------+---------+----------+--------------+-------------
 5  id     | integer |           | not null |         | plain    |              | 
 6  name   | text    |           |          |         | extended |              | 
 7 Indexes:
 8     "test2_pkey" PRIMARY KEY, btree (id)
 9 Distribute By: HASH(id)
10 Location Nodes: ALL DATANODES
11 
12 postgres=# select * from test2 order by id;
13  id  | name 
14 -----+------
15    1 | 1
16    2 | b
17    3 | 3
18    4 | 4
19    5 | 5
20    6 | 
21  111 | 
22  112 | 
23 (8 rows)
24 
25 postgres=# select * from test2 a inner join test4 b on a.id=b.id order by a.id;
26 2018-11-08 15:09:19.389 CST [1206] WARNING:  Unexpected data on connection, cleaning.
27  id | name | id 
28 ----+------+----
29   2 | b    |  2
30   4 | 4    |  4
31   6 |      |  6
32 (3 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在以后的版本中,能把這些限制給解決掉,越做越完善。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM