MySQL Forums
Forum List  »  Triggers

Using variable in trigger - high CPU usage problem
Posted by: Robert Bielik
Date: June 28, 2012 03:35AM

Hi,

I have a trigger which is executed AFTER INSERT on a "state" table (where values are inserted/removed rapidly), to accumulate the state changes into another table. This is only done for certain INSERTs where an id column has a certain value which changes over time so I use a function for that, like:

SET @value=GET_VALUE(CURRENT_TIMESTAMP);
IF (new.id=@value) THEN
   INSERT INTO `accu_table` (id, ...columns...) VALUES(N, ...columns...);
END IF;

but this skyrocketed the servers CPU usage to 100%.

So pretty much I'd like to be able to do this with lesser CPU usage.

Ideas?
/Rob



Edited 1 time(s). Last edit at 06/28/2012 05:38AM by Robert Bielik.

Options: ReplyQuote


Subject
Views
Written By
Posted
Using variable in trigger - high CPU usage problem
3174
June 28, 2012 03:35AM


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.