problem description
the following SQL statement exists:
SELECT `h1`.`oid`,`hr`.`uid`,`h1`.`bid`,`isself`,`tag`,h1.name as hname,
h1.add as hadd,
case when isself=1 then h2.name else h3.name end name ,
case when isself=1 then h2.add else h3.add end add
FROM `interv` `h1`
LEFT JOIN `relative` `hr` ON `h1`.`relative`=hr.relative and h1.oid=hr.oid
LEFT JOIN `self` `h2` ON `hr`.`uid`=`h2`.`uid`
LEFT JOIN `scrapy` `h3` ON `hr`.`uid`=`h3`.`uid`
WHERE `h1`.`upon` = 1
and (case when isself=1 then h2.status else h3.status end)=2
*and (case when isself=1 then h2.cid else h3.cid end)=2*
order by h1.updatetime desc,
h1.createtime desc
limit 50
the environmental background of the problems and what methods you have tried
now I"m building a joint index for updatetime,createtime in H1, joint indexes for status and cid in tables of H2 and h3, and then indexes for status and cid separately. But now the execution efficiency is poor. The explain is as follows
wherecase when cid0.2s1s+
: