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

视图查询排序慢,关联字段已加索引
表结构如下:
CREATE TABLE `username` (  
  `id` int(10) NOT NULL auto_increment,  
  `username` varchar(50) character set utf8 collate utf8_unicode_ci default '',  
  `userpwd` varchar(50) character set utf8 collate utf8_unicode_ci default NULL,  
  `Role_id` varchar(50) character set utf8 collate utf8_unicode_ci default NULL,  
  `fid` smallint(6) default NULL,  
  `pathint` varchar(500) character set utf8 collate utf8_unicode_ci default NULL,  
  `locked` tinyint(1) default '1',  
  `name` varchar(100) character set utf8 collate utf8_unicode_ci default NULL,  
  `company` varchar(200) character set utf8 collate utf8_unicode_ci default NULL,  
  `credit` int(11) default '0',  
  `tel` varchar(100) character set utf8 collate utf8_unicode_ci default NULL,  
  `dizhi` varchar(100) character set utf8 collate utf8_unicode_ci default NULL,  
  `mail` varchar(80) character set utf8 collate utf8_unicode_ci default NULL,  
  `content` text character set utf8 collate utf8_unicode_ci,  
  `meun` varchar(200) default NULL,  
  `smsjk` tinyint(4) default '0',  
  `audit` tinyint(4) default '0',  
  `priority` tinyint(4) default '0',  
  `shi` timestamp NULL default NULL,  
  PRIMARY KEY (`id`),  
  UNIQUE KEY `user_name` (`user_name`)  
  ) ENGINE=MyISAM AUTO_INCREMENT=49 DEFAULT CHARSET=utf

CREATE TABLE `phone` (  
  `id` bigint(20) NOT NULL auto_increment,  
  `sid` bigint(20) default NULL,  
  `needCallNumber` char(50) collate utf8_unicode_ci default '',  
  `caller` char(255) collate utf8_unicode_ci default NULL,  
  `content` varchar(300) collate utf8_unicode_ci default NULL,  
  `jk` varchar(50) collate utf8_unicode_ci default NULL,  
  `pathint` varchar(300) collate utf8_unicode_ci default NULL,  
  `shi` timestamp NULL default CURRENT_TIMESTAMP,  
  PRIMARY KEY (`id`),  
  KEY `NewIndex1` (`needCallNumber`)  
  ) ENGINE=MyISAM AUTO_INCREMENT=93494 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci 
================================================================================================
视图userView中是用上表中的phone.nee