question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pagination over large tables slow

See original GitHub issue

There is a significant performance drop in Oracle’s adapter for EF Core compared to EF6 when selecting from a table with 2 million rows. EF6 is using a different approach for computing the row number required for paging.

EF6

SELECT * 
FROM ( 
SELECT 
"Extent1"."Id" AS "Id"
FROM ( SELECT "Extent1"."Id" AS "Id", row_number() OVER (ORDER BY "Extent1"."Id" DESC) AS "row_number"
	FROM "Table" "Extent1"
)  "Extent1"
WHERE ("Extent1"."row_number" > :p__linq__0)
ORDER BY "Extent1"."ID" DESC
)
WHERE (ROWNUM <= (:p__linq__1))

EF Core

Select
 K0 "Id"
 from (
  select 
    "m2".*, 
    rownum r2 
  from
    (
    SELECT "t"."Id" K0
    FROM "Table" "t"

    ORDER BY "t"."Id" DESC
    ) "m2"
) "m1"
where r2 > :p_0
and r2 <= (:p_0 + :p_1)

I am using Oracle 11g (11.2.0.3.0) and have set compatibility level to 11 when configuring the DbContext.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:31 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
alexkehcommented, May 10, 2021

Got the repro. We’ll take a look.

1reaction
alexkehcommented, Nov 17, 2020

@iulianb I just toggled the bug status to be viewable to customers. Within 24 hours, you should be able to view the bug from MOS. I don’t know why Oracle Support couldn’t find it. They should be able to view internal bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Seek paginated query gets progressively slower on a big ...
Seek paginated query gets progressively slower on a big table ; SELECT ; = ; NULL ; timestamp ; 'a58b' ; OR ;,...
Read more >
Why is Offset Pagination So Slow - Level Up Coding
In short, the offset limit pagination performs generally slower than the cursor pagination when handling large offset. However, the choice of ...
Read more >
[TIL-6] Why pagination is slow? - davidasync - Medium
Pagination is a process that is used to divide large data into smaller discrete pages, and this process is also known as paging....
Read more >
Efficient Pagination on MySQL – Iterate Over Large Tables
Some devs are complaining that their queries - using offset - are getting really slow when they iterate over a really big MySQL...
Read more >
Pagination: Slow ORDER BY with large LIMIT range
The large the limit, the more it takes to complete making the page slow to load. I have already added indexes, however it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found