MySQL解释说明主表的索引不在生产服务器上使用

我正在尝试从OsCommerce优化以下修改的MySQL查询:
select distinct p.products_id, pd.products_name, m.manufacturers_name, s.specials_new_products_price from products p 
inner join products_description pd on p.products_id = pd.products_id
inner join products_to_categories p2c on p.products_id = p2c.products_id 
left join manufacturers m on p.manufacturers_id = m.manufacturers_id 
left join specials s on p.products_id = s.products_id and s.specials_b2bgroup =0 
where p.products_status = '1' and p.products_model not like '%_VIP' and pd.language_id = '4' and p2c.categories_id = '1574' 
order by p.products_ordernum, p.products_model
在生产服务器上运行说明似乎在连接时没有用于表产品的索引:
id  select_type     table   type    possible_keys   key     key_len     ref     rows    Extra
1   SIMPLE  p   ALL     PRIMARY     NULL        NULL NULL   6729    Using where; Using temporary; Using filesort
1   SIMPLE  m   eq_ref  PRIMARY     PRIMARY     4   p.manufacturers_id  1    
1   SIMPLE  s   ref     products_id products_id 4   p.products_id   2    
1   SIMPLE  pd  eq_ref  PRIMARY     PRIMARY     8   p.products_id,const     1    
1   SIMPLE  p2c eq_ref  PRIMARY     PRIMARY     8   pd.products_id,const    1   Using where; Using index; Distinct
表产品的架构如下:
CREATE TABLE IF NOT EXISTS `products` (
  `products_id` int(11) NOT NULL auto_increment,
  `products_model` varchar(50) default NULL,
  `products_image` varchar(250) default NULL,
  `products_price` decimal(15,4) NOT NULL default '0.0000',
  `products_date_added` datetime NOT NULL default '0000-00-00 00:00:00',
  `products_last_modified` datetime default NULL,
  `products_date_available` datetime default NULL,
  `products_weight` decimal(5,2) NOT NULL default '0.00',
  `products_status` tinyint(1) NOT NULL default '0',
  `products_showprod` tinyint(1) NOT NULL default '0',
  `products_showprice` tinyint(1) NOT NULL default '0',
  `products_ordernum` int(6) NOT NULL default '100',
  `products_tax_class_id` int(11) NOT NULL default '0',
  `manufacturers_id` int(11) default NULL,
  PRIMARY KEY  (`products_id`),
  KEY `idx_products_model` (`products_model`),
) ENGINE=MyISAM  DEFAULT CHARSET=greek AUTO_INCREMENT=1;
我的服务器的MySQL版本是5.0.92。欢迎任何关于在哪里寻找解决方案的想法!     
已邀请:
products
表上的查询中只有两个约束,您已将其声明为“主”表(因为其他所有内容都是
JOIN ON
):
products_status
(未编入索引)和
products_model
。但是
NOT LIKE '%...'
不是可索引的约束,因此执行简单扫描更快。 如果
%
位于
LIKE
模式的中间或末尾,则该指数将非常有用。即便如此,
NOT
仍然可以使线性扫描更快。     
products
是嵌套循环中的前导(最外层)表,因此用于访问此表的索引与连接无关。 这个条件:
p.products_model not like '%_VIP'
不是傻瓜。 你可以尝试在
products (status)
上创建一个索引,如果它有足够的选择性(即there14的值很少)     

要回复问题请先登录注册