Nah Anda meminta ulang DB berulang kali untuk data yang sudah Anda ketahui.
Mengapa tidak memperbarui ringkasan dengan perubahan saja.
DELIMITER $$
CREATE TRIGGER ai_base_each AFTER INSERT ON base FOR EACH ROW
BEGIN
INSERT INTO summary (status, count) VALUES (NEW.status,1)
ON DUPLICATE KEY UPDATE
SET count = count + 1;
END $$
CREATE TRIGGER ad_base_each AFTER DELETE ON base FOR EACH ROW
BEGIN
UPDATE summary s
SET s.count = s.count - 1
WHERE s.status = OLD.status;
END $$
CREATE TRIGGER au_base_each AFTER UPDATE ON base FOR EACH ROW
BEGIN
UPDATE summary s
SET s.count = s.count - 1
WHERE s.status = OLD.status;
INSERT INTO summary (status, count) VALUES (NEW.status,1)
ON DUPLICATE KEY UPDATE
SET count = count + 1;
END $$
DELIMITER ;
Ini akan jauh lebih cepat dan jauh lebih elegan.