Author: ikelly
Date: 2008-10-17 19:00:20 -0500 (Fri, 17 Oct 2008)
New Revision: 9235

Modified:
   django/trunk/django/db/backends/oracle/query.py
Log:
Fixed #9136: Do slicing in Oracle with rownum instead of row_number() for a 
speed improvement. Thanks, Guillaume Taglang.

Modified: django/trunk/django/db/backends/oracle/query.py
===================================================================
--- django/trunk/django/db/backends/oracle/query.py     2008-10-17 22:46:08 UTC 
(rev 9234)
+++ django/trunk/django/db/backends/oracle/query.py     2008-10-18 00:00:20 UTC 
(rev 9235)
@@ -111,9 +111,10 @@
                 # 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
 


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to django-updates@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to