pt-archiver deleting all records in the where

Hello
I am a newbie to percona toolkit so bear with me.

I am trying to archive data from a mysql innodb database to a mysql archive database.

When I run a test dry run I get these queries back which when executed give the desired results.

SELECT /*!40001 SQL_NO_CACHE / id,accountid,description,datecreated,backofficeonly,operatorid FROM axxessnew.ax_history_account FORCE INDEX(PRIMARY) WHERE (1=1) AND (id < ‘4241395’) ORDER BY id LIMIT 4
SELECT /
!40001 SQL_NO_CACHE */ id,accountid,description,datecreated,backofficeonly,operatorid FROM axxessnew.ax_history_account FORCE INDEX(PRIMARY) WHERE (1=1) AND (id < ‘4241395’) AND ((id >= ?)) ORDER BY id LIMIT 4
DELETE FROM axxessnew.ax_history_account WHERE (((id >= ?))) AND (((id <= ?))) AND (1=1) LIMIT 4
LOAD DATA LOCAL INFILE ? INTO TABLE axxess_archive.ax_history_account(id,accountid,description,datecreated,backofficeonly,operatorid)

however when I run the command without the dry run it deletes everything from the table except one record

pt-archiver --dry-run --ascend-first --no-check-charset --bulk-insert --where “1=1” --limit 4 --commit-each --source h=127.0.0.1,D=axxessnew,u=user,t=ax_history_account --dest h=127.0.0.1,D=axxess_archive,u=user,p=“pass”,t=ax_history_account

What am I doing wrong.

1 Like

1 . --where “1=1” you where statement matches all entries.
2. you do not have an --no-delete that says don’t delete the original data.

1 Like