Look at this example:
2.1.3 :001 > Stat.create!
(0.1ms) BEGIN
SQL (0.3ms) INSERT INTO `stats` (`created_at`, `updated_at`) VALUES (\'2015-03-16 11:
Answer of Alejandro Babio is extensive but wanted to explain why transaction is done in the first place.
This answer explains what role does the transaction have in the call. Here is it in short:
begin transaction
insert record
after_save called
commit transaction
after_commit called
But provided no after_save
hook is registered by developer, I wonder why transaction is not skipped. For high latency connections, the transaction may increase overall operation time 3 times :/ IMO Rails needs to be optimized.
Rails rejected such optimization, see why: https://github.com/rails/rails/issues/26272