Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Linq SQL generation for pagination

3664697Mar 1 2018 — edited Mar 5 2018

Using EF6 and ODP.NET 12.2 I have the following query:

db.SAMPLES.OrderBy(p => p.NAME).ThenBy(p => p.DESCRIPTION).Skip(0).Take(10).ToList();

I'm wondering why this can be translated to:

SELECT *

FROM (

SELECT

"Extent1"."ID" AS "ID",

"Extent1"."NUMBER" AS "NUMBER",

"Extent1"."NAME" AS "NAME",

"Extent1"."DESCRIPTION" AS "DESCRIPTION"

FROM ( SELECT "Extent1"."ID" AS "ID", "Extent1"."NUMBER" AS "NUMBER", "Extent1"."NAME" AS "NAME", "Extent1"."DESCRIPTION" AS "DESCRIPTION", row_number() OVER (ORDER BY "Extent1"."NAME" ASC, "Extent1"."DESCRIPTION" ASC) AS "row_number"

  FROM "ZENKI"."SAMPLEs" "Extent1"

)  "Extent1"

WHERE ("Extent1"."row_number" > 0)

ORDER BY "Extent1"."NAME" ASC, "Extent1"."DESCRIPTION" ASC

)

WHERE (ROWNUM <= (10) )

It seems to me that the line in bold is not needed, is already sorted in the inner FROM, but instead is killing the query performance. ¿Why?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 2 2018
Added on Mar 1 2018
2 comments
875 views