20171207.sql
893 Bytes
use webapm;
DELIMITER $$
CREATE PROCEDURE `p_del_slow`(IN `date_inter` INT)
BEGIN
DELETE FROM slow_duration WHERE (TO_DAYS(NOW()) - TO_DAYS(FROM_UNIXTIME(create_time/1000)))>=date_inter;
END$$
DELIMITER ;
DELIMITER $$
CREATE PROCEDURE `p_del_error`(IN `date_inter` INT)
BEGIN
DELETE FROM error_report WHERE (TO_DAYS(NOW()) - TO_DAYS(FROM_UNIXTIME(create_time/1000)))>=date_inter;
END$$
DELIMITER ;
set global event_scheduler=1;
CREATE EVENT `e_del_slow_route`
ON SCHEDULE EVERY 1 DAY STARTS '2017-12-7 0:0:0'
ON COMPLETION PRESERVE DISABLE
DO CALL p_del_slow (7);
CREATE EVENT `e_del_error_report`
ON SCHEDULE EVERY 1 DAY STARTS '2017-12-7 0:0:0'
ON COMPLETION PRESERVE DISABLE
DO CALL p_del_error (7);
alter event e_del_slow_route on completion preserve enable;
alter event e_del_error_report on completion preserve enable;
ALTER TABLE slow_duration ADD useragent varchar(200);