diff options
| author | Ian Kelly <ian.g.kelly@gmail.com> | 2008-10-18 00:00:20 +0000 |
|---|---|---|
| committer | Ian Kelly <ian.g.kelly@gmail.com> | 2008-10-18 00:00:20 +0000 |
| commit | 934025e58d03be49e9fe8bdd54c99d73373137ea (patch) | |
| tree | 301078bb6a8d5abcbc4a844818f0eee2d5a8d12b | |
| parent | 9feebb10f91cb7faf00b6a83ea5a7d03f739e421 (diff) | |
Fixed #9136: Do slicing in Oracle with rownum instead of row_number() for a speed improvement. Thanks, Guillaume Taglang.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9235 bcc190cf-cafb-0310-a4f2-bffc1f526a37
| -rw-r--r-- | django/db/backends/oracle/query.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/django/db/backends/oracle/query.py b/django/db/backends/oracle/query.py index 4bdce9225c..6935f2c681 100644 --- a/django/db/backends/oracle/query.py +++ b/django/db/backends/oracle/query.py @@ -111,9 +111,10 @@ def query_class(QueryClass, Database): # Wrap the base query in an outer SELECT * with boundaries on # the "_RN" column. This is the canonical way to emulate LIMIT # and OFFSET on Oracle. - sql = 'SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY 1) AS "_RN", "_SUB".* FROM (%s) "_SUB") WHERE "_RN" > %d' % (sql, self.low_mark) + high_where = '' if self.high_mark is not None: - sql = '%s AND "_RN" <= %d' % (sql, self.high_mark) + high_where = 'WHERE ROWNUM <= %d' % (self.high_mark,) + sql = 'SELECT * FROM (SELECT ROWNUM AS "_RN", "_SUB".* FROM (%s) "_SUB" %s) WHERE "_RN" > %d' % (sql, high_where, self.low_mark) return sql, params |
