首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > Mysql >

mysql慢查询,该如何解决

2012-10-11 
mysql慢查询SQL code# User@Host: witdeals_db[witdeals_db] @ localhost []# Query_time: 153.044546Lock

mysql慢查询

SQL code
  # User@Host: witdeals_db[witdeals_db] @ localhost []  # Query_time: 153.044546  Lock_time: 111.693284 Rows_sent: 0  Rows_examined: 6  SET timestamp=1349326288;  DELETE FROM seo_cache WHERE cache_expires <= '2012-10-03 23:48:55';  # User@Host: witdeals_db[witdeals_db] @ localhost []  # Query_time: 153.045285  Lock_time: 102.696872 Rows_sent: 0  Rows_examined: 6  SET timestamp=1349326288;  DELETE FROM seo_cache WHERE cache_expires <= '2012-10-03 23:48:55';  # User@Host: witdeals_db[witdeals_db] @ localhost []  # Query_time: 153.389527  Lock_time: 96.306026 Rows_sent: 0  Rows_examined: 6  SET timestamp=1349326288;  DELETE FROM seo_cache WHERE cache_expires <= '2012-10-03 23:48:55';  # User@Host: witdeals_db[witdeals_db] @ localhost []  # Query_time: 153.388131  Lock_time: 101.468448 Rows_sent: 0  Rows_examined: 6


SQL code
-- phpMyAdmin SQL Dump-- version 3.4.11.1-- http://www.phpmyadmin.net---- 主机: localhost-- 生成日期: 2012 年 10 月 07 日 10:55-- 服务器版本: 5.1.65-- PHP 版本: 5.2.6SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";SET time_zone = "+00:00";---- 数据库: `witdeals_main`---- ------------------------ 表的结构 `seo_cache`--CREATE TABLE IF NOT EXISTS `seo_cache` (  `cache_id` varchar(32) CHARACTER SET latin1 NOT NULL DEFAULT '',  `cache_language_id` tinyint(1) NOT NULL DEFAULT '0',  `cache_name` varchar(255) CHARACTER SET latin1 NOT NULL DEFAULT '',  `cache_data` mediumtext CHARACTER SET latin1 NOT NULL,  `cache_global` tinyint(1) NOT NULL DEFAULT '1',  `cache_gzip` tinyint(1) NOT NULL DEFAULT '1',  `cache_method` varchar(20) CHARACTER SET latin1 NOT NULL DEFAULT 'RETURN',  `cache_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',  `cache_expires` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',  PRIMARY KEY (`cache_id`,`cache_language_id`),  KEY `cache_id` (`cache_id`),  KEY `cache_language_id` (`cache_language_id`),  KEY `cache_global` (`cache_global`)) ENGINE=MyISAM DEFAULT CHARSET=utf8;

单独执行又很快。。不知道怎么回事

[解决办法]
create index xxx on seo_cache(cache_expires );

热点排行