Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL slow queries

The MySQL slow query log often shows a bunch of following entries in sequence.

SET timestamp=1268999330;
commit;
# User@Host: username[username] @ localhost []
# Query_time: 4.172700  Lock_time: 0.000000 Rows_sent: 0  Rows_examined: 0
SET timestamp=1268999330;
commit;
# User@Host: username[username] @ localhost []
# Query_time: 3.628924  Lock_time: 0.000000 Rows_sent: 0  Rows_examined: 0
SET timestamp=1268999330;
commit;
# User@Host: username[username] @ localhost []
# Query_time: 3.116018  Lock_time: 0.000000 Rows_sent: 0  Rows_examined: 0
...

Usually 6-7 "commit" queries in sequence. Anyone what they are and what's the preceding query of each of them?

Thanks in advance.

like image 393
jack Avatar asked Mar 20 '10 06:03

jack


1 Answers

the set timestamp command affects the value returned by now and the value that auto timestamp columns receive when their rows are modified.

this is necessary for replication and when playing back the log. query semantics that depend on the current time will always match exactly. (note sysdate disregards set timestamp unlike now)

the log will make sure the timestamp is recorded with set timestamp whenever there's a new connection, a mysql ping, or any statement executed.

like image 111
user262976 Avatar answered Sep 20 '22 20:09

user262976