急急急 Mysql中sql语句优化 江湖救急

数据库 专栏收录该内容
3 篇文章 0 订阅

Mysql优化 sql语句优化

这是我遇到的一句sql语句 执行时间为2s多
select t . USER_ID AS USER_ID ,
(select u . USER_NAME from auth_user u
where ( u . ID = t . USER_ID )) AS USER_NAME , r . ID AS ID , r . RES_NAME AS RES_NAME , r . RES_EN_NAME AS RES_EN_NAME ,
r . RES_TYPE AS RES_TYPE , r . RES_IS_SYS AS RES_IS_SYS , r . RES_LINK AS RES_LINK , r . SORT AS SORT , r . CREATE_TIME AS CREATE_TIME ,
r . CREATE_USER_ID AS CREATE_USER_ID , r . UPDATE_TIME AS UPDATE_TIME , r . UPDATE_USER_ID AS UPDATE_USER_ID , r . MOD_ID AS MOD_ID ,
(select m . MOD_NAME from auth_module m where ( m . ID = r . MOD_ID )) AS MOD_NAME , r . DOM_ID AS DOM_ID ,
(select d . DOM_NAME from auth_domain d where ( d . ID = r . DOM_ID )) AS DOM_NAME ,
(select d . DOM_APP_CODE from auth_domain d where ( d . ID = r . DOM_ID )) AS DOM_APP_CODE , r . OPER_ID AS OPER_ID ,
(select o . OPER_DEF_CODE from auth_operation_define o where ( o . ID = r . OPER_ID )) AS OPER_DEF_CODE ,
(select o . OPER_DEF_VALUE from auth_operation_define o where ( o . ID = r . OPER_ID )) AS OPER_DEF_VALUE ,
(select o . OPER_DEF_CATEGORY from auth_operation_define o where ( o . ID = r . OPER_ID )) AS OPER_DEF_CATEGORY , r . MNU_ID AS MNU_ID ,
(select m . MNU_NAME from auth_menu m where ( m . RES_ID = r . ID )) AS MNU_NAME ,(select m . MNU_PARENT_ID from auth_menu m
where ( m . RES_ID = r . ID )) AS MNU_PARENT_ID , t . ROLE_RES_SCOPE AS ROLE_RES_SCOPE
from v_auth_user_resource_t t JOIN auth_resource r where ( t . RES_ID = r . ID )

v_auth_user_resource_t mysql视图

select ur . USER_ID AS USER_ID , rr . RES_ID AS RES_ID , rr . ROLE_RES_SCOPE AS ROLE_RES_SCOPE
from ( auth_role_resource rr JOIN auth_user_role ur )
where ( ur . ROLE_ID = rr . ROLE_ID )

where 条件后的第一个字段我都加了索引 但是查询效率还是2s多
有哪位大佬给点sql优化建议?

  • 0
    点赞
  • 3
    评论
  • 0
    收藏
  • 打赏
    打赏
  • 扫一扫,分享海报

©️2022 CSDN 皮肤主题:大白 设计师:CSDN官方博客 返回首页

打赏作者

康三说

你的鼓励将是我创作的最大动力

¥2 ¥4 ¥6 ¥10 ¥20
输入1-500的整数
余额支付 (余额:-- )
扫码支付
扫码支付:¥2
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值