What is the ideal Composite Index in MySQL for the following query on an InnoDB Table1?
SELECT ColA
FROM Table1
WHERE ColB = 0
AND ColC = 0
AND ColD = 0
ColA is the left-most Primary Key.
ColB has fewer "0" rows than ColC, and ColC has fewer "0" results than ColD.
When using the composite index (ColB, ColC, ColD) on the query above, MySQL is instead using an Intersect of Indices ColB, ColC, and ColD.
Here is the requested SHOW CREATE TABLE Table1 ;
results:
CREATE TABLE `Table1` (
`ColA` int(11) unsigned NOT NULL,
`ColE` mediumint(8) unsigned NOT NULL DEFAULT '0',
`ColF` mediumint(8) unsigned NOT NULL DEFAULT '0',
`ColB` mediumint(8) unsigned NOT NULL DEFAULT '0',
`ColG` mediumint(8) unsigned NOT NULL DEFAULT '0',
`ColC` mediumint(8) unsigned NOT NULL DEFAULT '0',
`ColH` mediumint(8) unsigned NOT NULL DEFAULT '0',
`ColD` mediumint(8) unsigned NOT NULL DEFAULT '0',
`ColJ` mediumint(8) unsigned NOT NULL DEFAULT '0',
`ColK` mediumint(8) unsigned NOT NULL DEFAULT '0',
`ColM` mediumint(8) unsigned NOT NULL DEFAULT '0',
`ColP` mediumint(8) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`ColA`),
KEY `ColB` (`ColB`),
KEY `ColG` (`ColG`),
KEY `ColC` (`ColC`),
KEY `ColH` (`ColH`),
KEY `ColD` (`ColD`),
KEY `ColJ` (`ColJ`),
KEY `ColK` (`ColK`),
KEY `ColB_2` (`ColB`,`ColC`,`ColD`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1