开发者

Triggers in a highly Transactional System

We are creating a highly transactional system with MySQL as DB (innodb engine). We have one insert and update trigger on table t1 which is updating table t2 and t3. We have observed that whenever concurrent user volume is high we are getting dead-lock on table t1. We are assuming that trigger is issuing a table-lock until it's completing it's execution. We dropped the trigger on t1 and surprisingly there is no deadlock anymore.

My question:

  1. Is it not recommend开发者_开发问答ed to have trigger in a highly transactional system
  2. If not trigger what are our other options to implement the same logic.

Table t1 is having about 70,000 rows and increasing on a daily basis.

Appreciate any inputs.

Thanks in advance.


You can use transactions instead and do all processing client side.

START TRANSACTION;

insert into t1;
update t2;
update t3;

COMMIT;

Try and not use 'update select' and 'insert select' constructs if you can get away with using client provided data. Also InnoDB uses row-locking which is better than the table locking that MyISAM uses.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜