日期:2014-05-16  浏览次数:20659 次

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.6

SET 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 );