MySQL Forums
Forum List  »  InnoDB

AFTER INSERT Triggers execute in serial or in parallel?
Posted by: Pedro Guillem
Date: May 06, 2013 02:36AM

Hi all.

I'm trying to process CDR records (bill phone calls) using an AFTER INSERT trigger. I figured this is best than having a third party app do it each minute.


The sequence is as follows:

1) A phone call is finished and a new call record is inserted on table 1.

2) A trigger is fired AFTER inserting a row in table 1.

3) The trigger performs 5 select statements to bill the call and inserts the billed record on table 2.

4) The trigger updates the balance of the account owner of the call and finishes.


The biggest problem i´m seeing here is i will be billing at least 50 calls per second and i don´t know the exact behavior this will cause; since the balance of the account is being read before the process and updated afterwards.

My question is simple: If 50 cdrs are created in 1 second, will the fired triggers execute in parallel? or serialized?... This is vital, as if they execute in parallel the balance of the account may not be updated in order.

Out of the 5 queries performed to calculate the call, 2 of them are performed over a 40.000 row table holding the rates. This is taking 0.230 seconds per inner query, but the balance is updated at the very end of the script.

If two fired triggers start at the same time they will start processing the call with the same balance, and it will be useless.

Any toughts?

Options: ReplyQuote


Subject
Views
Written By
Posted
AFTER INSERT Triggers execute in serial or in parallel?
3017
May 06, 2013 02:36AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.