Django

Code

Changeset 9235

Show
Ignore:
Timestamp:
10/17/08 19:00:20 (3 months ago)
Author:
ikelly
Message:

Fixed #9136: Do slicing in Oracle with rownum instead of row_number() for a speed improvement. Thanks, Guillaume Taglang.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/backends/oracle/query.py

    r9221 r9235  
    112112                # the "_RN" column.  This is the canonical way to emulate LIMIT 
    113113                # 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 = '' 
    115115                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) 
    117118 
    118119            return sql, params