SELECT COUNT(0) FROM xxxxx WHERE ROW_ID!=1773 and ( USER_ACCOUNT = '18969662823' OR (USER_PHONE = '18969662823'  AND USER_PHONE_YZ_FLAG = '1'));在线等。

解决方案 »

  1.   

    先看看优化相关的内容吧  http://blog.csdn.net/baidu_23174957/article/details/41649343
      

  2.   

    在user_accout和user_phone上分别加索引
    select sum(a) from (
    SELECT COUNT(0) as a FROM xxxxx WHERE ROW_ID!=1773 and  USER_ACCOUNT = '18969662823'   AND USER_PHONE_YZ_FLAG = '1'
    union all
    SELECT COUNT(0) as a FROM xxxxx WHERE ROW_ID!=1773 and USER_PHONE = '18969662823' AND USER_PHONE_YZ_FLAG = '1')T
      

  3.   

    select sum(k) from (
    SELECT COUNT(0) as k FROM xxxxx 
    WHERE ROW_ID!=1773 
    and USER_ACCOUNT = '18969662823' 
    union all
    SELECT COUNT(0) FROM xxxxx 
    WHERE ROW_ID!=1773 
    and USER_PHONE = '18969662823'  AND USER_PHONE_YZ_FLAG = '1'
    ) t然后创建索引。
    create index xx1 on xxxxx(USER_ACCOUNT,ROW_ID);
    create index xx2 on xxxxx(USER_PHONE,USER_PHONE_YZ_FLAG,ROW_ID);