Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#28670 closed Cleanup/optimization (fixed)

Add native LIMIT/OFFSET support on Oracle.

Reported by: Markus Stenberg Owned by: Mariusz Felisiak
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Currently the code which does the LIMIT+OFFSET clause emulation there with ROWNUM (which assorted sources on the internet recommend not to do) is no longer needed. Oracle 12 supports SQL syntax for this:

https://oracle-base.com/articles/12c/row-limiting-clause-for-top-n-queries-12cr1

[ OFFSET offset { ROW | ROWS } ]
[ FETCH { FIRST | NEXT } [ { rowcount | percent PERCENT } ]
    { ROW | ROWS } { ONLY | WITH TIES } ]

This applies to all versions, but is probably reasonable to implement in 2.0+ onlyas then there is no need to worry about Oracle 11 which does not support the syntax.

Change History (7)

comment:1 Changed 5 years ago by Mariusz Felisiak

Triage Stage: UnreviewedAccepted
Version: 2.0master

comment:2 Changed 5 years ago by Mariusz Felisiak

Owner: changed from nobody to Mariusz Felisiak
Status: newassigned
Summary: django/db/backends/oracle/compiler.py handling of LIMIT+OFFSET could be better in Oracle 12+.Add native LIMIT/OFFSET support on Oracle.

comment:3 Changed 5 years ago by GitHub <noreply@…>

In 03da070:

Refs #28670 -- Moved LIMIT/OFFSET SQL to DatabaseOperations.limit_offset_sql().

Thanks Tim Graham for the review.

comment:4 Changed 5 years ago by Mariusz Felisiak

Has patch: set

comment:5 Changed 5 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:6 Changed 5 years ago by GitHub <noreply@…>

Resolution: fixed
Status: assignedclosed

In 0899d583:

Fixed #28670 -- Added FETCH/OFFSET support on Oracle.

Thanks Tim Graham for the review.

comment:7 Changed 4 years ago by GitHub <noreply@…>

In f0082b9:

Refs #28670 -- Fixed DatabaseFeatures.supports_slicing_ordering_in_compound on Oracle.

Note: See TracTickets for help on using tickets.
Back to Top