Why do I see so many ROCLBACK commands in the Pt-query-digest output?
I don’t understand how does it make sense.
Hello @Idan_Ahal,
ROLLBACK typically comes from your application code. If you are using an ORM, or other framework, these typically do this automatically. In PMM, there is a graph that tracks these such DML like BEGIN, COMMIT, and ROLLBACK.
You can look in the slow query log for a ROLLBACK command, and find the associated connection ID, which will then show you other queries executed. Perhaps that will help you discover the source of the ROLLBACKs.
I can see there is a rollback after every SELECT I do. Why is that? Isn’t that redundant? Doesn’t it add overhead?
That would be your ORM/framework/code doing it. It is technically redundant, as SELECTs start out as read-only transactions. It doesn’t add any noticeable overhead since the transaction doesn’t modify any pages which would need to be rolled back or purged.