InfiniteWP has a setting to automatically delete log data that is older than 30, 60 or 90 days. You can’t use that if you send clients a yearly maintenance report. In that case you can only delete data that is older then a year, or 13 months, so that needs to be done manually. You can do it every month, or when InfiniteWP starts to get very slow. That’s usually when the total IWP database size reaches about 900mb. After clearing the log, about 500mb is left.
The InfiniteWP log is located in the following database tables:
- infwp_history
- infwp_history_additional_data
- infwp_history_raw_details
The tables are related to each other with the historyID
Run the following query to find the historyID and time entry of that record (last field in the results) from 13 month old entries.
SELECT *, FROM_UNIXTIME(`microtimeAdded`) FROM `infwp_history` WHERE `microtimeAdded` < UNIX_TIMESTAMP(DATE_SUB(curdate(), INTERVAL 13 MONTH)) ORDER BY `historyID` DESC LIMIT 1Code language: JavaScript (javascript)
To remove all older records from infwp_history
DELETE FROM `infwp_history` WHERE `microtimeAdded` < UNIX_TIMESTAMP(DATE_SUB(curdate(), INTERVAL 13 MONTH))Code language: JavaScript (javascript)
To remove all associated records from infwp_history_additional_data
DELETE FROM `infwp_history_additional_data` WHERE `historyID` NOT IN (SELECT `historyID` FROM `infwp_history`)Code language: JavaScript (javascript)
To remove all associated records from infwp_history_raw_details
(not clear if needed)
DELETE FROM `infwp_history_raw_details` WHERE `historyID` NOT IN (SELECT `historyID` FROM `infwp_history`)Code language: JavaScript (javascript)
Alternative queries
You can also delete records bases on the historyID (replace 000000 with the ID you found in step 1).
DELETE FROM `infwp_history` WHERE `historyID` <= 000000
DELETE FROM `infwp_history_additional_data` WHERE `historyID` <= 000000
DELETE FROM `infwp_history_raw_details` WHERE `historyID` <= 000000Code language: JavaScript (javascript)
If delete doesn’t work (error server has gone away)
- make a selection of what you want to keep and copy it into a new table
- empty the original table
- copy the data of the new table into the original table
- delete the new table if necessary
CREATE TABLE infwp_history-nieuw
SELECT *
FROM `infwp_history` WHERE `historyID` > 859123
CREATE TABLE infwp_history_additional_data-nieuw
SELECT *
FROM `infwp_history_additional_data` WHERE `historyID` > 859123
INSERT INTO infwp_history_additional_data
SELECT *
FROM `infwp_history_additional_data-nieuw`
INSERT INTO infwp_history
SELECT *
FROM `infwp_history-nieuw`Code language: JavaScript (javascript)