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

JdbcExpert拼接SQL增加占位符“?”,加快查询 #1569

Open
wisebuilder opened this issue Dec 19, 2020 · 1 comment
Open

JdbcExpert拼接SQL增加占位符“?”,加快查询 #1569

wisebuilder opened this issue Dec 19, 2020 · 1 comment

Comments

@wisebuilder
Copy link

wisebuilder commented Dec 19, 2020

public void formatQuery(Sql sql) {

        Pager pager = sql.getContext().getPager();
        // 需要进行分页
        if (null != pager && pager.getPageNumber() > 0)
            sql.setSourceSql(sql.getSourceSql()
                             + String.format(" LIMIT %d, %d",
                                             pager.getOffset(),
                                             pager.getPageSize()));
    }

这个“LIMIT %d, %d”建议最后使用占位符 “LIMIT @pageOffset, @pageSize”

@wendal
Copy link
Member

wendal commented Dec 19, 2020

有区别吗? 最新的mysql会有差异?

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

No branches or pull requests

2 participants