automatic purge of search history #2211

Open
opened 2026-10-05 01:09:54 +02:00 by adam · 3 comments
Owner

https://piwigo.org/forum/viewtopic.php?id=34799

This user reports a piwigo_search table with 4.7 millions lines. Crazy. I copy my thoughts here :

There is currently no mecanism to purge the piwigo_search table. We should add one. To implement it the "right way" I would like to have a piwigo_search.last_used_on column, so that we could only purge lines matching "not used for 1 month" (for example). However we have piwigo_history.search_id, so we can have a first idea.

The piwigo_history table is automatically purged, based on a maximum number of rows. The piwigo_search table should also be purged, but maybe more based on a "not used for X days" rule.

https://piwigo.org/forum/viewtopic.php?id=34799 This user reports a `piwigo_search` table with 4.7 millions lines. Crazy. I copy my thoughts here : > There is currently no mecanism to purge the piwigo_search table. We should add one. To implement it the "right way" I would like to have a piwigo_search.last_used_on column, so that we could only purge lines matching "not used for 1 month" (for example). However we have piwigo_history.search_id, so we can have a first idea. The `piwigo_history` table is automatically purged, based on a maximum number of rows. The `piwigo_search` table should also be purged, but maybe more based on a "not used for X days" rule. <!-- github-sync-id:4309878320 -->
Author
Owner

... and also, if the piwigo_search.created_by matches $conf['guest_id'], then I think there is no need to keep them more than X days.

Another idea would be to be able to "save this search" (and name it), have them in a user menu and be able to delete them. The saved searches would not be automatically purged.

... and also, if the `piwigo_search.created_by` matches `$conf['guest_id']`, then I think there is no need to keep them more than X days. Another idea would be to be able to "save this search" (and name it), have them in a user menu and be able to delete them. The saved searches would not be automatically purged. <!-- github-comment-id:4304249804 -->
Author
Owner

By the way, we already have a "purge search history" action in the maintenance screen, but it's an "all in" action. It "truncates" the table.

By the way, we already have a "purge search history" action in the maintenance screen, but it's an "all in" action. It "truncates" the table. <!-- github-comment-id:4304278924 -->
Author
Owner

May I add my support for this. I have very recently had a problem when my Piwigo (docker version) kept giving odd errors making it come to a stop and effectively unavailable. Looking at the docker logs for Piwigo first, there are hundreds of line accumulating, each including something like

"GET /index.php?/tags/ [lots of my tags here] ....... "meta-externalagent/1.1 (+https://developers.facebook.com/docs/sharing/webmasters/crawler)"

I also looked at the MariaDB tables and 'repaired' them. This brought the site back to life. The piwigo_search table is being added to at about 30 entries per minute! The rule for each search query is something like "a:2:{s:4:"mode";s:3:"AND";s:6:"fields";a:4:{s:8:"allwords";a:3:{s:5:"words";a:0:{}s:4:"mode";s:3:"AND";s:6:"fields";a:7:{i:0;s:4:"file";i:1;s:4:"name";i:2;s:7:"comment";i:3;s:4:"tags";i:4;s:6:"author";i:5;s:9:"cat-title";i:6;s:8:"cat-desc";}}s:3:"cat";a:2:{s:5:"words";a:0:{}s:7:"sub_inc";b:1;}s:4:"tags";a:2:{s:5:"words";a:21:{i:0;s:1:"7";i:1;s:2:"12";i:2;s:2:"18";i:3;s:2:"29";i:4;s:2:"33";i:5;s:2:"41";i:6;s:2:"46";i:7;s:2:"48";i:8;s:2:"49";i:9;s:2:"59";i:10;s:2:"67";i:11;s:2:"69";i:12;s:3:"104";i:13;s:3:"172";i:14;s:3:"217";i:15;s:3:"235";i:16;s:3:"669";i:17;s:4:"1124";i:18;s:4:"1126";i:19;s:4:"1137";i:20;s:4:"1148";}s:4:"mode";s:3:"AND";}s:12:"date_created";a:1:{s:6:"preset";s:0:"";}}}"

I also purged the search history from within Piwigo itself. By looking at the MariaDB database, the table did empty but soon built up very quickly before your eyes.

I am not an expert here so may be completely wrong in my diagnosis, but it is not sensible to have to clear the search history every day or two and would appreciate somewhere to set up a search limit.

Thank you

May I add my support for this. I have very recently had a problem when my Piwigo (docker version) kept giving odd errors making it come to a stop and effectively unavailable. Looking at the docker logs for Piwigo first, there are hundreds of line accumulating, each including something like "GET /index.php?/tags/ _[lots of my tags here]_ ....... "meta-externalagent/1.1 (+https://developers.facebook.com/docs/sharing/webmasters/crawler)" I also looked at the MariaDB tables and 'repaired' them. This brought the site back to life. The piwigo_search table is being added to at about 30 entries per minute! The rule for each search query is something like "a:2:{s:4:"mode";s:3:"AND";s:6:"fields";a:4:{s:8:"allwords";a:3:{s:5:"words";a:0:{}s:4:"mode";s:3:"AND";s:6:"fields";a:7:{i:0;s:4:"file";i:1;s:4:"name";i:2;s:7:"comment";i:3;s:4:"tags";i:4;s:6:"author";i:5;s:9:"cat-title";i:6;s:8:"cat-desc";}}s:3:"cat";a:2:{s:5:"words";a:0:{}s:7:"sub_inc";b:1;}s:4:"tags";a:2:{s:5:"words";a:21:{i:0;s:1:"7";i:1;s:2:"12";i:2;s:2:"18";i:3;s:2:"29";i:4;s:2:"33";i:5;s:2:"41";i:6;s:2:"46";i:7;s:2:"48";i:8;s:2:"49";i:9;s:2:"59";i:10;s:2:"67";i:11;s:2:"69";i:12;s:3:"104";i:13;s:3:"172";i:14;s:3:"217";i:15;s:3:"235";i:16;s:3:"669";i:17;s:4:"1124";i:18;s:4:"1126";i:19;s:4:"1137";i:20;s:4:"1148";}s:4:"mode";s:3:"AND";}s:12:"date_created";a:1:{s:6:"preset";s:0:"";}}}" I also purged the search history from within Piwigo itself. By looking at the MariaDB database, the table did empty but soon built up very quickly before your eyes. I am not an expert here so may be completely wrong in my diagnosis, but it is not sensible to have to clear the search history every day or two and would appreciate somewhere to set up a search limit. Thank you <!-- github-comment-id:4877289709 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/Piwigo#2211