1、创建一个products表
mysql> CREATE TABLE products (
-> id INT PRIMARY KEY AUTO_INCREMENT,
-> product_name VARCHAR(100),
-> price DECIMAL(13 , 2 )
-> );
Query OK, 0 rows affected (0.17 sec)
2、查看products表结构
mysql> desc select count(*) from products;
+----------------------------+----------+-----------+----------------+---------------------------------+
| id | estRows | task | access object | operator info |
+----------------------------+----------+-----------+----------------+---------------------------------+
| StreamAgg_16 | 1.00 | root | | funcs:count(Column#6)->Column#4 |
| └─TableReader_17 | 1.00 | root | | data:StreamAgg_8 |
| └─StreamAgg_8 | 1.00 | cop[tikv] | | funcs:count(1)->Column#6 |
| └─TableFullScan_15 | 10000.00 | cop[tikv] | table:products | keep order:false, stats:pseudo |
+----------------------------+----------+-----------+----------------+---------------------------------+
4 rows in set (0.00 sec)
注意此时是cop[tikv],证明还不是tiflash的数据结构
3、为tidb的表products创建tiflash副本
mysql> ALTER TABLE products SET TIFLASH REPLICA 1;
Query OK, 0 rows affected (0.19 sec)
4、再次查看products表结构
mysql> desc select count(*) from products;
+------------------------------+----------+--------------+----------------+---------------------------------+
| id | estRows | task | access object | operator info |
+------------------------------+----------+--------------+----------------+---------------------------------+
| HashAgg_21 | 1.00 | root | | funcs:count(Column#6)->Column#4 |
| └─TableReader_23 | 1.00 | root | | data:ExchangeSender_22 |
| └─ExchangeSender_22 | 1.00 | mpp[tiflash] | | ExchangeType: PassThrough |
| └─HashAgg_9 | 1.00 | mpp[tiflash] | | funcs:count(1)->Column#6 |
| └─TableFullScan_20 | 10000.00 | mpp[tiflash] | table:products | keep order:false, stats:pseudo |
+------------------------------+----------+--------------+----------------+---------------------------------+
5 rows in set (0.00 sec)
此时为mpp[tiflash],表示已经创建了tiflash的副本
如上,我们可以看到当tidb的环境tikv与tiflash部署成功之后,想使用tiflash的引擎,按照如上的操作即可完成
作者:Syw