Merge pull request #3488 from omnivore-app/drop-db-triggers

fix: drop db triggers which updates labels and highlights in library_item table for locking the table
This commit is contained in:
Hongbo Wu
2024-02-02 10:38:59 +08:00
committed by GitHub
2 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,11 @@
-- Type: DO
-- Name: drop_slow_db_triggers
-- Description: Drop some db triggers which are slow and have cascading effect
BEGIN;
DROP TRIGGER IF EXISTS library_item_labels_update ON omnivore.entity_labels;
DROP TRIGGER IF EXISTS library_item_highlight_annotations_update ON omnivore.highlight;
DROP TRIGGER IF EXISTS label_names_update ON omnivore.labels;
COMMIT;

View File

@ -0,0 +1,23 @@
-- Type: UNDO
-- Name: drop_slow_db_triggers
-- Description: Drop some db triggers which are slow and have cascading effect
BEGIN;
CREATE TRIGGER label_names_update
AFTER UPDATE ON omnivore.labels
FOR EACH ROW
WHEN (OLD.name <> NEW.name)
EXECUTE FUNCTION update_label_names();
CREATE TRIGGER library_item_highlight_annotations_update
AFTER INSERT OR UPDATE OR DELETE ON omnivore.highlight
FOR EACH ROW
EXECUTE FUNCTION update_library_item_highlight_annotations();
CREATE TRIGGER library_item_labels_update
AFTER INSERT OR UPDATE OR DELETE ON omnivore.entity_labels
FOR EACH ROW
EXECUTE FUNCTION update_library_item_labels();
COMMIT;