【问题标题】:Which data node the table is stored, how to query in postgres-xl?表存储在哪个数据节点,在postgres-xl中如何查询?
【发布时间】:2015-02-27 07:43:48
【问题描述】:

创建表时不使用distribute sub语句。

如果有2个节点,如何查询表的实际存储位置?

如果有两张表属于同一个schema,它们会存储在不同的数据节点吗?

【问题讨论】:

    标签: postgresql database-partitioning postgres-xl


    【解决方案1】:

    来自文档:

    If DISTRIBUTE BY is not specified, columns with UNIQUE constraint
    will be chosen as the distribution key. If no such column is
    specified, distribution column is the first eligible column 
    in the definition. If no such column is found, then the table 
    will be distributed by ROUNDROBIN.
    

    在您的用例场景中,在不使用 TO NODE 节点名指令或指定分发方法的情况下创建表时,将在所有数据节点中创建该表,并且行通过哈希或循环在数据节点之间分布。

    您可以使用 EXECUTE DIRECT(这是 Postgres-XL 特有的 SQL 命令)查看哪些数据节点中有哪些行:

    test_db=# CREATE TABLE test (id integer UNIQUE, name varchar(30) NULL);
    CREATE TABLE
    test_db=# insert into test (id, name) values (0,'0test');
    INSERT 0 1
    test_db=# insert into test (id, name) values (1,'1test');
    INSERT 0 1
    test_db=# insert into test (id, name) values (2,'2test');
    INSERT 0 1
    test_db=# insert into test (id, name) values (3,'3test');
    INSERT 0 1
    test_db=# EXECUTE DIRECT ON (datanode1) 'select * from test';
     id | name
    ----+-------
      1 | 1test
      2 | 2test
    (2 rows)
    
    test_db=# EXECUTE DIRECT ON (datanode2) 'select * from test';
     id | name
    ----+-------
      0 | 0test
      3 | 3test
    (2 rows)
    

    正如我刚刚提到的,如果您使用 TO NODE 节点名TO GROUP 组名,则可以将表存储在某个数据节点上。

    【讨论】:

      猜你喜欢
      • 2015-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-03
      • 2018-01-07
      • 2015-12-21
      • 2011-09-16
      • 2010-10-02
      相关资源
      最近更新 更多