Total size: 624 M Total download size: 19 M Is this ok [y/d/N]: y ... Installed: greatsql-client.x86_64 0:8.0.32-25.1.el7 greatsql-devel.x86_64 0:8.0.32-25.1.el7 greatsql-icu-data-files.x86_64 0:8.0.32-25.1.el7 greatsql-mysql-router.x86_64 0:8.0.32-25.1.el7 greatsql-server.x86_64 0:8.0.32-25.1.el7 greatsql-shared.x86_64 0:8.0.32-25.1.el7
[root@shawnyan ~]# mysql -uroot -p'Greatsql@123' mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 15 Server version: 8.0.32-25 GreatSQL (GPL), Release 25, Revision 79f57097e3f
Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> \s -------------- mysql Ver 8.0.32-25 for Linux on x86_64 (GreatSQL (GPL), Release 25, Revision 79f57097e3f)
Connection id: 15 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 8.0.32-25 GreatSQL (GPL), Release 25, Revision 79f57097e3f Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8mb4 Db characterset: utf8mb4 Client characterset: latin1 Conn. characterset: latin1 UNIX socket: /var/lib/mysql/mysql.sock Binary data as: Hexadecimal Uptime: 55 min 51 sec
Threads: 2 Questions: 462 Slow queries: 0 Opens: 366 Flush tables: 3 Open tables: 279 Queries per second avg: 0.137 -------------- mysql> select version(); +-----------+ | version() | +-----------+ | 8.0.32-25 | +-----------+ 1 row in set (0.00 sec)
6. 查看第二引擎系统变量
这个版本的数据库提供了 9 个第二引擎的系统变量。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
mysql> show variables like '%secondary%'; +--------------------------------------------+----------------------+ | Variable_name | Value | +--------------------------------------------+----------------------+ | secondary_engine_cost_threshold | 100000.000000 | | secondary_engine_parallel_load_workers | 4 | | secondary_engine_read_delay_gtid_threshold | 100 | | secondary_engine_read_delay_level | TABLE_START_INC_TASK | | secondary_engine_read_delay_time_threshold | 60 | | secondary_engine_read_delay_wait_mode | WAIT_FOR_TRX | | secondary_engine_read_delay_wait_timeout | 60 | | show_create_table_skip_secondary_engine | OFF | | use_secondary_engine | OFF | +--------------------------------------------+----------------------+ 9 rows in set (0.00 sec)
7. 安装 Rapid 存储引擎
查看 Rapid 相关系统变量,由于尚未安装插件,所以查询结果为空。
1 2
mysql> show variables like '%rapid%'; Empty set (0.00 sec)
mysql> show create table t\G *************************** 1. row *************************** Table: t Create Table: CREATE TABLE `t` ( `a` int DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci 1 row in set (0.00 sec)
加载数据到 Rapid 引擎。
1 2
mysql> alter table t secondary_load; Query OK, 0 rows affected (0.02 sec)
需要注意的是,需要先进行 load 再查询数据,否则会报错。
1 2
mysql> explain analyze select /*+ set_var(use_secondary_engine=forced) */ * from t\G ERROR 3889 (HY000): Secondary engine operation failed. use_secondary_engine is FORCED but query could not be executed in secondary engine.
9. Rapid 的使用
使用 Hint 强制使用 Rapid 引擎,并查看执行计划。
1 2 3 4 5 6 7 8 9
mysql> explain select /*+ set_var(use_secondary_engine=forced) */ * from t; +----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+------------------------------+ | id | select_type | table | partitions | type | possible_keys | key | key_len | ref | rows | filtered | Extra | +----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+------------------------------+ | 1 | SIMPLE | t | NULL | ALL | NULL | NULL | NULL | NULL | 1 | 100.00 | Using secondary engine RAPID | +----+-------------+-------+------------+------+---------------+------+---------+------+------+----------+------------------------------+ 1 row in set, 1 warning (0.00 sec)
Note (Code 1003): /* select#1 */ select /*+ SET_VAR(use_secondary_engine='forced') */ `sbtest`.`t`.`a` AS `a` from `sbtest`.`t`
不过,目前不支持 explain analyze 语法。
1 2
mysql> explain analyze select /*+ set_var(use_secondary_engine=forced) */ * from t; ERROR 1235 (42000): This version of MySQL doesn't yet support 'EXPLAIN ANALYZE with secondary engine'
mysql> CREATE TABLE partitioned_table ( -> id INT, -> name VARCHAR(50), -> date_created DATE -> ) -> PARTITION BY RANGE (YEAR(date_created)) ( -> PARTITION p0 VALUES LESS THAN (1991), -> PARTITION p1 VALUES LESS THAN (1992) -> ); Query OK, 0 rows affected (0.01 sec)
mysql> alter table partitioned_table secondary_load; ERROR 3877 (HY000): The partition table is not supported for RAPID
此外,也不支持整个库同时加载到 Rapid 引擎。
1 2
mysql> alter database sbtest secondary_engine = rapid; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'secondary_engine = rapid' at line 1