You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following query defined in MenuMapper.xml is not optimal:
<selectid="getMenusByRoleIds"resultType="cn.stylefeng.guns.base.pojo.node.MenuNode">
SELECT
m1.menu_id AS id,
m1.code AS code,
m1.icon AS icon,
(
CASE
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN
0
ELSE
m2.menu_id
END
) AS "parentId",
m1.name as name,
m1.url as url,
m1.levels as levels,
m1.menu_flag as ismenu,
m1.system_type as systemType,
m1.sort as num
FROM
sys_menu m1
LEFT join sys_menu m2 ON m1.pcode = m2.code
INNER JOIN (
SELECT
menu_id
FROM
sys_menu
WHERE
menu_id IN (
SELECT
menu_id
FROM
sys_relation rela
WHERE
rela.role_id IN
<foreachcollection="list"index="index"item="i"open="("separator=","close=")">
#{i}
</foreach>
)
) m3 ON m1.menu_id = m3.menu_id
where m1.menu_flag = 'Y'
order by levels,m1.sort asc
</select>
The INNER JOIN for m3 is unnecessary and could be optimized out to the following:
<selectid="getMenusByRoleIds"resultType="cn.stylefeng.guns.base.pojo.node.MenuNode">
SELECT
m1.menu_id AS id,
m1.code AS code,
m1.icon AS icon,
(
CASE
WHEN (m2.menu_id = 0 OR m2.menu_id IS NULL) THEN
0
ELSE
m2.menu_id
END
) AS "parentId",
m1.name as name,
m1.url as url,
m1.levels as levels,
m1.menu_flag as ismenu,
m1.system_type as systemType,
m1.sort as num
FROM
sys_menu m1
LEFT join sys_menu m2 ON m1.pcode = m2.code
where m1.menu_flag = 'Y' and
m1.menu_id IN (
SELECT menu_id FROM sys_relation rela WHERE rela.role_id IN
<foreachcollection="list"index="index"item="i"open="("separator=","close=")">
#{i}
</foreach>
)
order by levels,m1.sort asc
</select>
The text was updated successfully, but these errors were encountered:
wtune
added a commit
to wtune/Guns
that referenced
this issue
Jan 10, 2020
The following query defined in MenuMapper.xml is not optimal:
The INNER JOIN for m3 is unnecessary and could be optimized out to the following:
The text was updated successfully, but these errors were encountered: