数据库
首页 > 数据库> > Oracle千万级数据分页查询优化

Oracle千万级数据分页查询优化

作者:互联网

Oracle千万级数据分页查询优化

1. 未优化之前:

SELECT TMP.* FROM (SELECT ROWNUM AS "ROWNO",${tableId},
${columnName}
            FROM ${tableName}) TMP
            WHERE
                TMP.ROWNO <= #{end}
                AND TMP.ROWNO >= #{start}

2.优化之后:

SELECT T1.${tableId},T1.${columnName}
FROM ${tableName} T1, (SELECT RID
                       FROM (SELECT
                               ROWNUM RN,
                               T.RID
                             FROM (SELECT
                                     ROWID RID
                                   FROM ${tableName}
                                  ) T
                             WHERE ROWNUM <= #{END})
                       WHERE RN > #{START}) T2
WHERE T1.ROWID = T2.RID

转载于:https://my.oschina.net/vright/blog/1543709

莫负好时光丶 发布了18 篇原创文章 · 获赞 16 · 访问量 2万+ 私信 关注

标签:TMP,ROWNO,分页,tableName,千万级,T1,Oracle,RID,SELECT
来源: https://blog.csdn.net/weixin_44569012/article/details/104082545