如何在系统表中查询表的hash分布列?

可以通过查询系统表gbase.table_distribution查询hash分布列。

gbase> create table t1(c1 int,c2 varchar(10)) distributed by ('c1');
Query OK, 0 rows affected (Elapsed: 00:00:00.22)

gbase> desc gbase.table_distribution;
+--------------------+--------------+------+-----+---------+-------+
| Field              | Type         | Null | Key | Default | Extra |
+--------------------+--------------+------+-----+---------+-------+
| index_name         | varchar(128) | NO   | PRI |         |       |
| dbName             | varchar(64)  | NO   |     | NULL    |       |
| tbName             | varchar(64)  | NO   |     | NULL    |       |
| isReplicate        | varchar(3)   | NO   |     | YES     |       |
| hash_column        | varchar(64)  | YES  |     | NULL    |       |
| lmt_storage_size   | bigint(20)   | YES  |     | NULL    |       |
| table_storage_size | bigint(20)   | YES  |     | NULL    |       |
| is_nocopies        | varchar(3)   | NO   |     | YES     |       |
+--------------------+--------------+------+-----+---------+-------+
8 rows in set (Elapsed: 00:00:00.00)

gbase> select * from gbase.table_distribution where dbname='guo' and tbname='t1'\G
*************************** 1. row ***************************
        index_name: guo.t1
            dbName: guo
            tbName: t1
       isReplicate: NO
       hash_column: c1
  lmt_storage_size: NULL
table_storage_size: NULL
       is_nocopies: NO
1 row in set (Elapsed: 00:00:00.00)

表中的hash_column字段即为hash分布列。

集群表名、字段名是否支持中文?

从862集群开始表名字段名支持中文字符,需要打开参数gcluster_extend_ident
参数gcluster_extend_ident,用来控制是否可以创建中文表名字段、特殊字符的字段。
默认为0,表示不开启,为1表示开启。
在gcluster_extend_ident为0的情况下,创建带有中文标识的库表,提示失败。
修改配置文件加入gcluster_extend_ident = 1,在不重启的情况下set global gcluster_extend_ident = 1开启,创建带有中文标识的库表,提示成功。

在8.6.2.18-R2.82869上测试,打开gcluster_extend_ident参数。

gbase> set global gcluster_extend_ident=1;
Query OK, 0 rows affected (Elapsed: 00:00:00.01)
gbase> \q
Bye
suse103:~ # gccli guo
GBase client 8.6.2.18-R2.82869. Copyright (c) 2004-2017, GBase.  All Rights Reserved.
gbase> create table 表(列1 int,列2 varchar(10));
Query OK, 0 rows affected (Elapsed: 00:00:01.10)

gbase> insert into 表 values(1,'a啊');
Query OK, 1 row affected (Elapsed: 00:00:00.03)

gbase> select * from 表;
 +------+------+
 | 列1  | 列2  |
 +------+------+
 |    1 | a啊  |
 +------+------+
1 row in set (Elapsed: 00:00:00.02)

为什么nocopies表不起作用?

8611版本集群建议不要使用nocopies表,后续版本将兼容nocopies属性,增加参数缺省关闭。建表时即使指定nocopies属性也按照正常表创建,基于性能考虑还可以使用nocopies表。

集群层sql和下发到节点层的sql,如何对应?

下发到节点层的sql中的注释信息包含集群层sql的id信息。
例如:
在集群层执行select * from lineorder;,下发节点gc层show processlist信息如下,sql id是102。

[root@pst-red214 ~]# gccli
GBase client 8.6.1.1-16.28.81413. Copyright (c) 2004-2017, GBase.  All Rights Reserved.
gbase> show processlist;
+-----+-----------------+-----------------+------+---------+-------+-----------------------------+-------------------------+
| Id  | User            | Host            | db   | Command | Time  | State                       | Info                    |
+-----+-----------------+-----------------+------+---------+-------+-----------------------------+-------------------------+
|   1 | event_scheduler | localhost       | NULL | Daemon  | 15044 | Waiting for next activation | NULL                    |
|  52 | root            | 127.0.0.1:38654 | NULL | Sleep   |  3414 |                             | NULL                    |
| 101 | root            | 127.0.0.1:38820 | NULL | Query   |     0 | NULL                        | show processlist        |
| 102 | root            | 127.0.0.1:38822 | guo  | Query   |     3 | Sending task to gnodes      | select * from lineorder |
+-----+-----------------+-----------------+------+---------+-------+-----------------------------+-------------------------+
4 rows in set (Elapsed: 00:00:00.00)

gn层show processlist如下,下发的sql中SELECT /*192.168.105.214_102_1_2017-07-03_14:28:29*/ /*+ TID('6561') */,包含集群层sql的id 102。

[root@pst-red214 ~]# gncli
GBase client 8.6.1.1-16.28.81413. Copyright (c) 2004-2017, GBase.  All Rights Reserved.
gbase> show processlist;
+-----+-------+-----------------------+---------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| Id  | User  | Host                  | db      | Command | Time | State        | Info                                                                                                 |
+-----+-------+-----------------------+---------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
| 539 | gbase | 192.168.105.212:10034 | gctmpdb | Sleep   | 9962 | NULL         | NULL                                                                                                 |
| 630 | root  | 127.0.0.1:61898       | NULL    | Query   |    0 | NULL         | show processlist                                                                                     |
| 631 | root  | 192.168.105.214:57013 | gctmpdb | Query   |    6 | Sending data | SELECT /*192.168.105.214_102_1_2017-07-03_14:28:29*/ /*+ TID('6561') */ `guo.lineorder`.`lo_orderkey |
+-----+-------+-----------------------+---------+---------+------+--------------+------------------------------------------------------------------------------------------------------+
3 rows in set (Elapsed: 00:00:00.00)