-- 将t1表上一次truncate的数据恢复到t2表中
FLASHBACK TABLE t1 TO T2;
-- 查询tidb_expensive_query_time_threshold变量,如果sql执行查询时间大于60秒,就会被记录到tidb.log中
mysql 5.7.25-TiDB-v5.3.0
mycli 1.20.1
Chat: https://gitter.im/dbcli/mycli
Mail: https://groups.google.com/forum/#!forum/mycli-users
Home: http://mycli.net
Thanks to the contributor - jweiland.net
mysql root@localhost:(none)>show variables like'%tidb_expensive_query_time_threshold%';+-------------------------------------+-------+| Variable_name |Value|+-------------------------------------+-------+| tidb_expensive_query_time_threshold |60|+-------------------------------------+-------+1rowinsetTime: 0.017s
-- 为了让更多的语句被记录,可以缩短这个时间,反之则增大这个时间
mysql root@localhost:(none)>set tidb_expensive_query_time_threshold=10;
Query OK,0rows affected
Time: 0.009s
mysql root@localhost:(none)>show variables like'%tidb_expensive_query_time_threshold%';+-------------------------------------+-------+| Variable_name |Value|+-------------------------------------+-------+| tidb_expensive_query_time_threshold |10|+-------------------------------------+-------+1rowinsetTime: 0.017s
more tidb.log | grep expensivequery
-- 查询tidb_mem_quota_query,其值表示,限制sql查询可以使用的最大内存1G,该参数是session级别的,只影响当前会话
mysql root@localhost:(none)>show variables like'%tidb_mem_quota_query%';+----------------------+------------+| Variable_name |Value|+----------------------+------------+| tidb_mem_quota_query |1073741824|+----------------------+------------+1rowinsetTime: 0.012s
-- 调小限制,防止OOM,内存会被限制,但可以使用磁盘
mysql root@localhost:(none)>set tidb_mem_quota_query=100000000;
Query OK,0rows affected
Time: 0.000s
mysql root@localhost:(none)>show variables like'%tidb_mem_quota_query%';+----------------------+-----------+| Variable_name |Value|+----------------------+-----------+| tidb_mem_quota_query |100000000|+----------------------+-----------+1rowinsetTime: 0.014s
mysql root@localhost:(none)>
more tidb.log | grep 'memory exceeds quota,spill to disk now'
-- 查看block-cache大小,建议范围总内存的(45%~60%)
MySQL root@localhost:mysql>SHOW config WHERE NAME='storage.block-cache.capacity';+------+-----------------+------------------------------+---------+|Type| Instance | Name |Value|+------+-----------------+------------------------------+---------+| tikv |127.0.0.1:20160| storage.block-cache.capacity |7274MiB |+------+-----------------+------------------------------+---------+1rowinsetTime: 0.010s
MySQL root@localhost:mysql>SHOW config WHERE NAME='storage.block-cache.capacity';+------+-----------------+------------------------------+---------+|Type| Instance | Name |Value|+------+-----------------+------------------------------+---------+| tikv |127.0.0.1:20160| storage.block-cache.capacity |7000MiB |+------+-----------------+------------------------------+---------+1rowinsetTime: 0.009s
MySQL root@localhost:mysql>