salix/db/routines/cache/procedures/visible_clean.sql

18 lines
376 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`visible_clean`()
BEGIN
DROP TEMPORARY TABLE IF EXISTS tCalc;
CREATE TEMPORARY TABLE tCalc
(INDEX (id))
ENGINE = MEMORY
SELECT id FROM cache_calc;
DELETE v
FROM visible v
LEFT JOIN tCalc c ON c.id = v.calc_id
WHERE c.id IS NULL;
DROP TEMPORARY TABLE tCalc;
END$$
DELIMITER ;