view MySQL/Plugins/GetLastChangeIndex.sql @ 560:b0ce1ebc9b90 find-refactoring

optimization
author Alain Mazy <am@orthanc.team>
date Sat, 14 Sep 2024 11:52:21 +0200
parents 740d9829f52e
children
line wrap: on
line source

CREATE TABLE IF NOT EXISTS GlobalIntegers(
       property INTEGER PRIMARY KEY,
       value BIGINT
       );


DELETE FROM GlobalIntegers WHERE property = 0;

INSERT INTO GlobalIntegers
SELECT 0, COALESCE(MAX(seq), 0) FROM Changes;


DROP TRIGGER IF EXISTS ChangeAdded;

CREATE TRIGGER ChangeAdded
AFTER INSERT ON Changes
FOR EACH ROW
BEGIN
  UPDATE GlobalIntegers SET value = new.seq WHERE property = 0@
END;