Database Management Statements

Last updated: 2020-05-11 14:32:17

PDF

If you want to view or download the full set of development documents, please see Development Guide for TDSQL.

Database Management Statements

Query status
You can view the configuration and status of the proxy through SQL. The following commands are currently supported:

    mysql> /*proxy*/help;
    +-----------------------+-------------------------------------------------------+
    | command               | description                                           |
    +-----------------------+-------------------------------------------------------+
    | show config           | show config from conf                                 |
    | show status           | show proxy status,like route,shardkey and so on       |
    | set sys_log_level=N   | change the sys debug level N should be 0,1,2,3        |
    | set inter_log_level=N | change the interface debug level N should be 0,1      |
    | set inter_time_open=N | change the interface time debug level N should be 0,1 |
    | set sql_log_level=N   | change the sql debug level N should be 0,1            |
    | set slow_log_level=N  | change the slow debug level N should be 0,1           |
    | set slow_log_ms=N     | change the slow ms                                    |
    | set log_clean_time=N  | change the log clean days                             |
    | set log_clean_size=N  | change the log clean size in GB                       |
    +-----------------------+-------------------------------------------------------+
    10 rows in set (0.00 sec)

    mysql> /*proxy*/show config;
    +-----------------+--------------------+
    | config_name     | value              |
    +-----------------+--------------------+
    | version         | V2R120D001         |
    | mode            | group shard        |
    | rootdir         | /shard_922         |
    | sys_log_level   | 0                  |
    | inter_log_level | 0                  |
    | inter_time_open | 0                  |
    | sql_log_level   | 0                  |
    | slow_log_level  | 0                  |
    | slow_log_ms     | 1000               |
    | log_clean_time  | 1                  |
    | log_clean_size  | 1                  |
    | rw_split        | 1                  |
    | ip_pass_through | 0                  |
    +-----------------+--------------------+
    14 rows in set (0.00 sec)

    mysql> /*proxy*/show status;
    +-----------------------------+------------------------------------------------------------------------------+
    | status_name                 | value                                                                        |
    +-----------------------------+------------------------------------------------------------------------------+
    | cluster                     | group_1499858910_79548                                                       |
    | set_1499859173_1:ip         | xxx.xxx.xxx.xxx:xxxx;xxx.xxx.xxx.xxx:xxxx@1@IDC_4@0,xxx.xxx.xxx.xxx:xxxx@1@IDC_2@0 |
    | set_1499859173_1:hash_range | 0---31                                                                       |
    | set_1499911640_3:ip         | xxx.xxx.xxx.xxx:xxxx;xxx.xxx.xxx.xxx:xxxx@1@IDC_4@0,xxx.xxx.xxx.xxx:xxxx@1@IDC_2@0 |
    | set_1499911640_3:hash_range | 32---63                                                                      |
    | set                         | set_1499859173_1,set_1499911640_3                                            |

Meanwhile, the proxy enhances the returned result of explain, showing the SQL statement modified by the proxy:

    mysql> explain select * from test1;
    +------+-------------+-------+------+---------------+------+---------+------+------+-------+-----------------------------------------+
    | id   | select_type | table | type | possible_keys | key  | key_len | ref  | rows | Extra | info                                    |
    +------+-------------+-------+------+---------------+------+---------+------+------+-------+-----------------------------------------+
    |    1 | SIMPLE      | test1 | ALL  | NULL          | NULL | NULL    | NULL |   16 |       | set_2,explain select * from shard.test1 |
    |    1 | SIMPLE      | test1 | ALL  | NULL          | NULL | NULL    | NULL |   16 |       | set_1,explain select * from shard.test1 |
    +------+-------------+-------+------+---------------+------+---------+------+------+-------+-----------------------------------------+
    2 rows in set (0.03 sec)