Very slow recording after adding Trigger in MYSQL Insertion

Asked

Viewed 68 times

0

When I insert this Rigger into my database it is taking a slow time, getting to give this message:

Errormessage: Lock Wait timeout exceeded; Try restarting transaction

My Trigger is as below, the cod_prod field of the products table is indexed correctly.

DELIMITER //

CREATE TRIGGER ESTOQUEENTRADA 
BEFORE INSERT

  ON estoque FOR EACH ROW

BEGIN

  UPDATE produtos SET quant_estoque = quant_estoque + NEW.quant_prod WHERE cod_prod = NEW.cod_prod;

END;//

DELIMITER;
  • Take a look here, sometimes it helps you: https://dba.stackexchange.com/questions/100506/why-update-trigger-makes-insertion-slow-in-mysql

  • Thanks for the help, but I checked all the items mentioned in the list and my script was not with any of the problems cited.

  • Have you tried to make the Trigger in the after instead of doing in the before?

  • I tried now in the after, the delay was the same.

  • I noticed that this only happens if the query is inside a transaction.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.