Author: ikelly
Date: 2008-10-17 19:02:26 -0500 (Fri, 17 Oct 2008)
New Revision: 9236

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

Backport of [9235] from trunk.



Property changes on: django/branches/releases/1.0.X
___________________________________________________________________
Name: svnmerge-integrated
   - 
/django/trunk:1-9097,9099-9102,9104-9109,9111,9113-9144,9146-9151,9153-9156,9158-9159,9161-9187,9189-9233
   + 
/django/trunk:1-9097,9099-9102,9104-9109,9111,9113-9144,9146-9151,9153-9156,9158-9159,9161-9187,9189-9233,9235

Modified: django/branches/releases/1.0.X/django/db/backends/oracle/query.py
===================================================================
--- django/branches/releases/1.0.X/django/db/backends/oracle/query.py   
2008-10-18 00:00:20 UTC (rev 9235)
+++ django/branches/releases/1.0.X/django/db/backends/oracle/query.py   
2008-10-18 00:02:26 UTC (rev 9236)
@@ -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