Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 934025e58d03be49e9fe8bdd54c99d73373137ea 1 parent 9feebb1
Ian Kelly authored October 18, 2008

Showing 1 changed file with 3 additions and 2 deletions. Show diff stats Hide diff stats

  1. 5  django/db/backends/oracle/query.py
5  django/db/backends/oracle/query.py
@@ -111,9 +111,10 @@ def as_sql(self, with_limits=True, with_col_aliases=False):
111 111
                 # Wrap the base query in an outer SELECT * with boundaries on
112 112
                 # the "_RN" column.  This is the canonical way to emulate LIMIT
113 113
                 # and OFFSET on Oracle.
114  
-                sql = 'SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY 1) AS "_RN", "_SUB".* FROM (%s) "_SUB") WHERE "_RN" > %d' % (sql, self.low_mark)
  114
+                high_where = ''
115 115
                 if self.high_mark is not None:
116  
-                    sql = '%s AND "_RN" <= %d' % (sql, self.high_mark)
  116
+                    high_where = 'WHERE ROWNUM <= %d' % (self.high_mark,)
  117
+                sql = 'SELECT * FROM (SELECT ROWNUM AS "_RN", "_SUB".* FROM (%s) "_SUB" %s) WHERE "_RN" > %d' % (sql, high_where, self.low_mark)
117 118
 
118 119
             return sql, params
119 120
 

0 notes on commit 934025e

Please sign in to comment.
Something went wrong with that request. Please try again.