select count(distinct t.test) from general_event t where exists(select distinct a.test from general_event_20130428 a where a.test=t.testand a.eventTag='你好' and eventid='hello') and eventid='world';
找出一张表中eventTag为‘你好’,eventid为'hello'的记录的test,然后根据test筛选eventid='world'的记录总数,不知道这么写对不对,但是好像一直在“正在查询”状态。有没有效率更高的方案?
找出一张表中eventTag为‘你好’,eventid为'hello'的记录的test,然后根据test筛选eventid='world'的记录总数,不知道这么写对不对,但是好像一直在“正在查询”状态。有没有效率更高的方案?
create index yyy on general_event_20130428(test,eventTag,eventid);
select count(distinct t.test)
from general_event t
where exists(select 1 from general_event_20130428 a where a.test=t.testand a.eventTag='你好' and eventid='hello')
and eventid='world';
select count(distinct t.test)
from general_event t
where exists(select 1 from general_event_20130428 a where a.test=t.testand a.eventTag='你好' and eventid='hello')
and eventid='world';
这个语句已经优化过了。好的,我试试,谢谢斑竹sql跑了10几分钟,还是一直“执行查询”,不知道哪儿出问题了