Commit Graph

16 Commits

Author SHA1 Message Date
Ben Dailey
4fe2103fcd Replace Events_Hour/Day/Week/Month/Archived and Event_Summaries tables with views
Remove denormalized event summary tables and their associated triggers,
replacing them with views that query the Events table directly. This
eliminates trigger maintenance overhead and periodic reconciliation in
zmaudit/zmstats, since the views compute stats on the fly.

- Remove trigger definitions for event summary table maintenance
- Remove event summary table inserts from zm_event.cpp
- Remove event count reconciliation queries from zmaudit.pl
- Remove DELETE-on-views calls from zmstats.pl (views filter by date inherently)
- Remove Event_Summaries DELETE from Monitor.php (can't delete from a view)
- Add db/views.sql with view definitions and covering index
- Add upgrade script zm_update-1.37.78.sql.in (drop triggers, drop tables, create views)
- Update zm_create.sql.in to use views instead of tables for fresh installs

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-04-07 11:29:30 -04:00
Isaac Connor
d64c5fa2c8 Remove events_insert_trigger 2026-01-24 11:16:07 -05:00
Isaac Connor
7c42215f2c Alter event_update_trigger to only update summary tables if there is a diskspace diff 2025-12-02 15:08:06 -05:00
Isaac Connor
ed57267258 Remove updating the Storage table in triggers. Do those updates manually because there is frequently too much contention around the Storage table and filters get locked on it. 2025-08-07 14:08:45 -04:00
Isaac Connor
cb35a6dd90 Handle case when OLD.DiskSpace is NULL 2024-07-09 08:12:52 -04:00
Isaac Connor
35b3d236e0 Fix typo in triggers 2021-04-09 19:47:08 -04:00
Isaac Connor
4e5ef01156 Fixup event summary column population, update triggers 2021-04-09 16:46:36 -04:00
Isaac Connor
c5ca123042 Move event summaries to their own table to reduce contention on Monitor_Status 2021-04-09 10:16:16 -04:00
Isaac Connor
63c78b43f8 Change event stats to Monitor_Status 2020-11-06 13:27:00 -05:00
Isaac Connor
adbd3486bf Rename StartTime, EndTime in Events to StartDateTime and EndDateTime 2020-11-04 13:49:39 -05:00
Isaac Connor
75b4f4f2b3 Add a few missing GREATESTs in the triggers. 2019-04-30 17:29:18 -04:00
Isaac Connor
3c56b32b08 Use GREATEST function prevent negative values in event counts 2019-04-24 10:38:08 -04:00
Isaac Connor
914c608dbc get rid of stored procedure. Do everything in the Trigger 2018-04-20 08:54:25 -04:00
Isaac Connor
0ad01f09bd refix triggers updating EventCounts. remove unsigned from eventcounts and diskspace totals. 2018-02-20 22:48:23 -05:00
Isaac Connor
e4ec1712f4 remove the table creation/dropping and a if/elseif fix 2018-02-18 11:48:00 -05:00
Isaac Connor
94212eda2f fix triggers 2018-02-18 11:01:33 -05:00