Last active
October 10, 2023 06:40
-
-
Save rkok/69f6f008f9dbca749129e28401b01dfd to your computer and use it in GitHub Desktop.
Cleanup InfiniteWP history tables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
################################################# | |
# For each site in InfiniteWP, | |
# removes all but the latest history records. | |
# | |
# This speeds up InfiniteWP and | |
# reduces the size of its tables, | |
# particularly iwp_history_raw_details. | |
# | |
# Indended to be run as a daily cronjob. | |
################################################# | |
echo "Cleaning up InfiniteWP outdated site history records" | |
set -x | |
mysql -N -s infinitewp -e 'delete from iwp_history where historyID not in ( select h.histID from ( select siteID, MAX(historyID) histID from iwp_history GROUP BY siteID ) h )' | |
mysql -N -s infinitewp -e 'delete from iwp_history_additional_data where historyID not in (select historyID from iwp_history)' | |
mysql -N -s infinitewp -e 'delete from iwp_history_raw_details where historyID not in (select historyID from iwp_history)' | |
set +x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment