MySQL Forums
Forum List  »  Stored Procedures

Re: SP vs Trigger
Posted by: Jay Pipes
Date: September 21, 2005 06:45AM

John,

I personally don't know of anything in the source code that would indicate one is "faster" than the other; I believe both stored procedures and triggers are handled in a similar fashion internally (as routines). The difference really is in when they get fired of course. Generally, however, I think a good rule of thumb is to try to put complex logic in stored procedures instead of triggers because they are a cleaner encapsulation of a single business transaction or function. Leave triggers to provide that additional functionality where you want to be able to "react" to a certain condition or field on a specific table when (either before or after) changes are made on specific columns in a table.

HTH,

p.s. Whether or not the issue of performance will change in the future is up for debate, however, as there may very well be performance improvements such as the caching of compiled execution plans built in to the stored procedure code, whereas I would see such performance improvements in trigger execution as slightly less likely (only because most triggers are unlikely to perform complex SELECT statements).

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Views
Written By
Posted
3001
September 19, 2005 10:06AM
Re: SP vs Trigger
2376
September 21, 2005 06:45AM


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.