开发者

Updating TimeStamp field a Slow Query in MySQL

My Table structure

CREATE TABLE IF NOT EXISTS `login` (
  `eMail` varchar(50) NOT NULL,
  `Password` tinytext NOT NULL,
  `UID` int(9) unsigned NOT NULL AUTO_INCREMENT,
  `Name` varchar(16) NOT NULL,
  `Text` tinytext NOT NULL,
  `OldText` tinytext NOT NULL,
  `LastSeen` timestamp NULL DEFAULT NULL,
  `SecurityQuestion` tinytext NOT NULL,
  `SecurityAnswer` tinytext NOT NULL,
  PRIMARY KEY (`UID`),
  UNIQUE KEY `eMail` (`eMail`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

When ever i try to update the LastSeen it shows as slow query [get logged into the slow query log file]

Can someone tell me whats wrong ?

A Sample SQL code [PHP]

$time = date("Y-m-d H:i:s");
UPDATE LO开发者_如何学JAVAGIN set LastSeen=? WHERE UID=?
mysqli_stmt_bind_param($stmt,"si",$time,$uid);

Edit:

I need the Timestamp cause i want to subtract current time with the data from the row. By default Timestam is automatically updated on each update, but it can be changed though [in my table the LastSeen filed is not automatically updated].


You shouldn't be updating a timestamp column: timestamp columns are automatically updated to the current time whenever you update the row.

If you want an updatable "timestamp" column in mysql, use the datetime datatype.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜