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
Open

Unnecessary subquery in MenuMapper.selectMenus #61

wtune opened this issue Jan 10, 2020 · 0 comments

Comments

@wtune
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant