1
我想问有关索引2个问题在MySQL:
1.是有可能有在MyISAM中发动机类型 HASH的指数?
2.是否有可能在计算值上创建索引,例如,
MySQL的复杂的索引
CREATE INDEX AD_MAIN_CATEGORY ON ad ((category_id % 100) ASC) USING BTREE;
我有查询选择所有类别和计数在主/副类别的广告数量。每个广告只有subcategory_id可以计算main_category_id(subcategory_id = 120 => main_category_id = 100)。邪恶(慢)查询:
SELECT `c`.*, (SELECT COUNT(*) FROM ad WHERE IF(c.parent_id = 0,(ad.category_id DIV 100) * 100 = c.id,ad.category_id=c.id)) AS `count`, `ct`.`label` FROM `category` AS `c` INNER JOIN `category_translation` AS `ct` ON c.id = ct.category_id WHERE (ct.language_id = 1) ORDER BY `c`.`id` ASC
非常感谢你:) – 2012-03-23 10:07:49