The Wayback Machine - https://web.archive.org/web/20201106095034/https://github.com/stylefeng/Guns/issues/61
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary subquery in MenuMapper.selectMenus #61

Open
wtune opened this issue Jan 10, 2020 · 0 comments · May be fixed by #62
Open

Unnecessary subquery in MenuMapper.selectMenus #61

wtune opened this issue Jan 10, 2020 · 0 comments · May be fixed by #62

Comments

@wtune
Copy link

@wtune wtune commented Jan 10, 2020

The following query defined in MenuMapper.xml is not optimal:

    <select id="selectMenus" resultType="map">
        select
        <include refid="Base_Column_List"/>
        from sys_menu
...
        <if test="menuId != null and menuId != 0">
            and (menu_id = #{menuId} or menu_id in ( select menu_id from sys_menu where pcodes like CONCAT('%$[', #{code}, '$]%') escape '$' ))
        </if>
    </select>

The sub-query could be eliminated and changes to a predicate on pcodes.

and (menu_id = #{menuId} or pcodes like CONCAT('%$[', #{code}, '$]%') escape '$' )
wtune added a commit to wtune/Guns that referenced this issue Jan 10, 2020
@wtune wtune linked a pull request that will close this issue Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.