Assume I have a table defined as follows:
create table t(id int primary key, c1 int,c2 int, idx_c2(c2))engine=innodb
I want to archive data satisfying the following condition:
c2>=value
When I use --dry-run
to run pt-archiver, it always picks up the primary key as the chunk index unless specifying the i
part in the --source
option.
SELECT /*!40001 SQL_NO_CACHE */ `id`,`c1`,`c2` FROM `test`.`t` FORCE INDEX(`idx_c2`) WHERE (c2>=6350) ORDER BY `c2` LIMIT 1000
Can this guarantee no duplicate rows to be archived? Because the SELECT generated has no guarantee it will not produce duplicate rows.
In fact, I expect the generated SELECT like the following:
SELECT /*!40001 SQL_NO_CACHE */ `id`,`c1`,`c2` FROM `test`.`t` FORCE INDEX(`idx_c2`) WHERE ((c2=? and id>? ) or c2>?) ORDER BY `c2`,`id` LIMIT 1000
and the ? is the last value for the last iteration.