John Smith
John Smith

Reputation: 275

Do mysql triggers produce extra overhead for select statements?

I know the obvious answer is no. But does having any of the insert, update, or delete triggers on a table affect a select statement to that same table in any way?

Upvotes: 2

Views: 154

Answers (1)

gaRex
gaRex

Reputation: 4215

No. 100%

MySQL processes triggers only in sql_delete.cc, sql_insert.cc and sql_update.cc.

See sources at mysql-5.5/sql directory. For example at http://bazaar.launchpad.net/~mysql/mysql-server/5.5/view/head:/sql/sql_insert.cc search for string ">process_triggers". It's an abstract insert, independently of concrete handler implementation.

When we look at the "select" part of sources at http://bazaar.launchpad.net/~mysql/mysql-server/5.5/view/head:/sql/sql_select.cc we just dont' see anywhere "trigger" in code (only 3 times in comments).

So officially I can report you, that during select triggers are not affected anywhere -- only on DML statements.

ps: See http://dev.mysql.com/doc/internals/en/guided-tour-skeleton.html to understand MySQL internals from bird's-eye.

Upvotes: 2

Related Questions