· 7 years ago · Sep 04, 2018, 05:28 PM
1MySQL explain shows that main table's indexes are not used at production server
2select distinct p.products_id, pd.products_name, m.manufacturers_name, s.specials_new_products_price from products p
3inner join products_description pd on p.products_id = pd.products_id
4inner join products_to_categories p2c on p.products_id = p2c.products_id
5left join manufacturers m on p.manufacturers_id = m.manufacturers_id
6left join specials s on p.products_id = s.products_id and s.specials_b2bgroup =0
7where p.products_status = '1' and p.products_model not like '%_VIP' and pd.language_id = '4' and p2c.categories_id = '1574'
8order by p.products_ordernum, p.products_model
9
10id select_type table type possible_keys key key_len ref rows Extra
111 SIMPLE p ALL PRIMARY NULL NULL NULL 6729 Using where; Using temporary; Using filesort
121 SIMPLE m eq_ref PRIMARY PRIMARY 4 p.manufacturers_id 1
131 SIMPLE s ref products_id products_id 4 p.products_id 2
141 SIMPLE pd eq_ref PRIMARY PRIMARY 8 p.products_id,const 1
151 SIMPLE p2c eq_ref PRIMARY PRIMARY 8 pd.products_id,const 1 Using where; Using index; Distinct
16
17CREATE TABLE IF NOT EXISTS `products` (
18 `products_id` int(11) NOT NULL auto_increment,
19 `products_model` varchar(50) default NULL,
20 `products_image` varchar(250) default NULL,
21 `products_price` decimal(15,4) NOT NULL default '0.0000',
22 `products_date_added` datetime NOT NULL default '0000-00-00 00:00:00',
23 `products_last_modified` datetime default NULL,
24 `products_date_available` datetime default NULL,
25 `products_weight` decimal(5,2) NOT NULL default '0.00',
26 `products_status` tinyint(1) NOT NULL default '0',
27 `products_showprod` tinyint(1) NOT NULL default '0',
28 `products_showprice` tinyint(1) NOT NULL default '0',
29 `products_ordernum` int(6) NOT NULL default '100',
30 `products_tax_class_id` int(11) NOT NULL default '0',
31 `manufacturers_id` int(11) default NULL,
32 PRIMARY KEY (`products_id`),
33 KEY `idx_products_model` (`products_model`),
34) ENGINE=MyISAM DEFAULT CHARSET=greek AUTO_INCREMENT=1;
35
36p.products_model not like '%_VIP'