show status like '%backquery%'
)。SELECT ... FROM <表名>AS OF TIMESTAMP <时间>;
MySQL [test]> create table t1(id int,c1 int) engine=innodb;Query OK, 0 rows affected (0.06 sec)MySQL [test]> insert into t1 values(1,1),(2,2),(3,3),(4,4);Query OK, 4 rows affected (0.01 sec)Records: 4 Duplicates: 0 Warnings: 0MySQL [test]> select now();+---------------------+| now() |+---------------------+| 2023-08-17 15:50:01 |+---------------------+1 row in set (0.00 sec)MySQL [test]> delete from t1 where id=4;Query OK, 1 row affected (0.00 sec)MySQL [test]> select * from t1;+------+------+| id | c1 |+------+------+| 1 | 1 || 2 | 2 || 3 | 3 |+------+------+3 rows in set (0.00 sec)MySQL [test]> select * from t1 as of timestamp '2023-08-17 15:50:01';+------+------+| id | c1 |+------+------+| 1 | 1 || 2 | 2 || 3 | 3 || 4 | 4 |+------+------+4 rows in set (0.00 sec)
create table t3 select * from t1 as of timestamp '2023-08-17 15:50:01';
insert into t4 select * from t1 as of timestamp '2023-08-17 15:50:01';
参数名 | 参数范围 | 类型 | 默认值 | 取值范围 | 是否需重启 | 说明 |
innodb_backquery_enable | 全局参数 | Boolean | OFF | ON/OFF | 否 | 闪回查询功能的开关 |
innodb_backquery_window | 全局参数 | Integer | 900 | 1 - 86400 | 否 | 支持闪回查询的时间范围,单位:秒,此参数的值越大,闪回查询支持的历史数据查询时间越长,同时 undo 表空间占用的存储空间也会上升 |
innodb_backquery_history_limit | 全局参数 | Integer | 8000000 | 1 - 9223372036854476000 | 否 | undo 的历史链表长度限制,超过设定值会忽略 Innodb_backquery_window 触发 purge,直到历史链表长度低于设定值 |
本页内容是否解决了您的问题?