Can pt-archiver be fed a file of PK's instead of using an index

I seems to vaguely remember that pt-archiver could be fed a file of PK values to do the nibbling for deletes or ETL extract (usually repeatable) rather than walking the index and selecting rows based on the where but cannot seem to find notes on this.

Anyone else remember doing this?

I think the method was similar to here Complex Archival with Percona Toolkit's pt-archiver - Percona Database Performance Blog

Thanks

Dom

2 Likes

Hi @rdab100

I was going to say that you would do it via the query in the --where, but that is in the article that you referenced. I don’t think that there is raw read that would do it, but you could parse the file in a script (e.g. mapfile) and inject those IDs into the query.

e.g.

=> cat ids.txt 
1
2
3
4

=> cat archive.sh
#!/bin/bash

declare -a ID_LIST=( )
declare WHERE_CLAUSE=

mapfile -t ID_LIST < ids.txt
WHERE_CLAUSE="$(echo "${ID_LIST[*]}" | tr ' ' ,)"

echo "pt-archiver ... --where 'id in (${WHERE_CLAUSE})'"

=> bash archive.sh 
pt-archiver ... --where 'id in (1,2,3,4)'

Hope that helps.

Ceri

1 Like