Ok, so I have this table called Users (id) and another one called UserTag (idUser, tag). Everytime a new user is created, I associate with it some tags.

idUser from UserTag is a foreign key of Users.id column.

I'm working with transaction (the problem only occurs with a transaction).

So, lets say I insert a new user. I retrieve the insert id of that and insert an entry in UserTag table.

1) Create a new user (create an entry in Users table)
2) Retrieve the newly created id from Users table
3) Insert a record in UserTag using that id.

When i try to do step 3, MySQL HANGS for several seconds (about 30 secs). If I remove the foreign key CONSTRAINT, everything works fine. If I execute the steps outside a transaction, everything works fine. This is happening only in my production enviroment.

Mysql version: 5.5.31-log - MySQL Community Server (GPL)

Appreciate any help!