Opened 7 years ago

Closed 7 years ago

Last modified 5 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 by Mariusz Felisiak, 7 years ago

Triage Stage: UnreviewedAccepted
Version: 2.0master

comment:2 by Mariusz Felisiak, 7 years ago

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 by GitHub <noreply@…>, 7 years ago

In 03da070:

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

Thanks Tim Graham for the review.

comment:4 by Mariusz Felisiak, 7 years ago

Has patch: set

comment:5 by Tim Graham, 7 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by GitHub <noreply@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In 0899d583:

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

Thanks Tim Graham for the review.

comment:7 by GitHub <noreply@…>, 5 years ago

In f0082b9:

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

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