Deleting old events

Forum for questions and support relating to the 1.34.x releases only.
Post Reply
RockUser
Posts: 20
Joined: Sun Jan 05, 2020 6:43 am

Deleting old events

Post by RockUser »

Hello all, I just need some help with setting up a filter that will auto delete old zoneminder events that are over 30 days old. I followed some threads on it but I must have messed something up with the date portion.
https://imgur.com/a/Y6CgFEf

For the date section after start date, I tried putting a number like "-30 days" like it says to in the FAQ
https://zoneminder.readthedocs.io/en/stable/faq.html

Purge By Age To delete events that are older than 7 days, create a new filter with “Date” set to “less than” and a value of “-7 days”, sort by “date/time” in “asc”ending order, then enable the checkbox “delete all matches”. You can also use a value of week or week and days: “-2 week” or “-2 week 4 day”
Doing this with "-30 days" just start deleting everything. So I was wondering if based on the screen shot if there's something obvious with my settings that I messed up.

I changed it to a specific date so that it would stop. But I originally had it at 30 days.
User avatar
iconnor
Posts: 2900
Joined: Fri Oct 29, 2010 1:43 am
Location: Toronto
Contact:

Re: Deleting old events

Post by iconnor »

It is entirely possible that there is a bug. Turn on debug logging and let's see what the resulting sql is.

That being said, you should actually try to use Start Date/Time because it is more efficient and more tested.

Why is it more efficient? because the resulting SQL is to_days( E.StartTime ) instead of just using E.StartTime. WHich means it can't use the index on StartTime. So it iterates every event in the db (unless another index comes into play).
bbunge
Posts: 2934
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: Deleting old events

Post by bbunge »

Here is a 30 day purge that has been working for me for a while:
day_purge.jpg
day_purge.jpg (81.68 KiB) Viewed 242633 times
RockUser
Posts: 20
Joined: Sun Jan 05, 2020 6:43 am

Re: Deleting old events

Post by RockUser »

bbunge wrote: Fri Jul 31, 2020 5:52 pm Here is a 30 day purge that has been working for me for a while:
day_purge.jpg
This worked for me thank you for sharing. :D
iconnor wrote:That being said, you should actually try to use Start Date/Time because it is more efficient and more tested.

Why is it more efficient? because the resulting SQL is to_days( E.StartTime ) instead of just using E.StartTime. WHich means it can't use the index on StartTime. So it iterates every event in the db (unless another index comes into play).
I will switch it to Date/Time then to save that extra bit of perfomance. Thank you for the advice. :D
Post Reply