Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8658581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:48:10+00:00 2026-06-12T15:48:10+00:00

I have a performance issue with Entity Framework 5 and Oracle DB. I have

  • 0

I have a performance issue with Entity Framework 5 and Oracle DB.

I have a simple SQL select: SELECT * FROM NOTE WHERE NOTENUMBER = '1A23456'

NOTENUMBER is included in an index on a table called NOTE, but the field is NOT primary key / unique.

  • When I execute the statement with Oracle SQL Developer, results return
    quickly and query plan shows that RANGE SCAN is being used like it
    should.

  • When I use Entity Framework, the generated SQL takes a lot
    longer (5 seconds vs. 30ms).

  • When I use Entity Framework and query
    with a primary key field (NOTE_KEY), results return as quickly as with SQL
    Developer.

I suspect 2 things:

  • There’s some problem with EF and Oracle.DataAccess-provider not using the non-unique-index that is available. It would help if I had debug symbols for Entity Framework 5, but I can’t find them anywhere.

  • The performance problem is somewhere in EF, regarding closures and/or the way I use generic repository pattern with EF:

    If I call my repository like this:
    var notenumber = "1A23456";
    var notes = repository.All(n => n.NOTENUMBER == notenumber).ToList();
    The predicate comes in at the method All as:
    {n => (n.NOTE == value(Tester.Program+<>c__DisplayClass0).notenumber)}
    And EfProf-profiler traces the resulting SQL as:

    SELECT "Extent1"."NOTE_KEY" AS "NOTE_KEY",
    "Extent1"."NOTENUMBER" AS "NOTENUMBER",
    "Extent1"."NOTETEXT" AS "NOTETEXT",
    FROM "NOTE_DBA"."NOTE" "Extent1"
    WHERE ("Extent1"."NOTENUMBER" = '1PSA0500237500' /* @p__linq__0 */)

    And the query takes takes ~5500ms.

    On the other hand, if I call my repository like this:
    var notes = repository.All(n => n.NOTENUMBER == "1A23456").ToList();
    Then the predicate comes in as:
    {n => (n.NOTENUMBER == "1A23456")}
    And EfProf-profiler traces the resulting SQL as:

    SELECT "Extent1"."NOTE_KEY" AS "NOTE_KEY",
    "Extent1"."NOTENUMBER" AS "NOTENUMBER",
    "Extent1"."NOTETEXT" AS "NOTETEXT",
    FROM "NOTE_DBA"."NOTE" "Extent1"
    WHERE ('1PSA0500237500' = "Extent1"."NOTENUMBER")

    And the query takes ~30ms.

    So the only difference is the order of the condition in the WHERE-clause, and the fact that in the latter there seems to be no parameter replaced by EF

I use VS2010 and .NET4, and reference EF5 (v4.4.0.0).
The repository’s All-method is:

public IQueryable<NOTE> All(Expression<Func<NOTE, bool>> predicate = null)
{
    var setOfNotes = GetDbSet<NOTE>();
    var notesQuery = from note in setOfNotes select note;
    if (predicate != null)
    {
        notesQuery = notesQuery.Where(predicate);
    }
    return notesQuery;
}

I tried to create a CompiledQuery, I tried using setOfNotes.AsNoTracking() and I tried to target .NET 4.5 – with no difference in performance.

One way I was able to get this particular query fast, was to use Oracle’s basic Data Provider for .NET (ODB.NET) and construct the query manually, but I’d rather not stick with that solution. Again, if I use a primary field in the where clause, the query is fast even with EF and the same All-method.

So the problem seems to be somewhere in EF. I feel could find out a lot more if I only had the symbols for EntityFramework.dll.

Could there be a problem with the way EF invokes predicates? How does the ‘@p_linq_0′-parameter get replaced inside EF?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:48:12+00:00Added an answer on June 12, 2026 at 3:48 pm

    I had a similar problem. The reason why the index wasn’t used in my case was that I was passing a string (unicode) from .NET as parameter. This was compared with a non-unicode database field.

    The solution was to convert the string parameter to non-unicode before passing it in the where clause:

    using System.Data.Objects;
    
    EntityFunctions.AsNonUnicode( myUnicodeParam)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background: Entity Framework 4, with SQL Server 2008 Problem: I have a table Order
I am running into an interesting performance issue with Entity Framework. I am using
I am using the Entity Framework 4.2 and I have a fairly serious performance
I'm encountering some major performance problems with simple SQL queries generated by the Entity
I have several performance issue in my website. I'm using asp.net mvc 2 and
i have a performance issue in my tableview my cellForRow looks like that: if
Just like in this topic , I have a performance issue in dev mode
I've got an performance issue in my application using a MSSQL DB. I have
I have just migrated to mysql 5.5.20 and I had a performance issue with
I have problem with my widget related to performance and memory: Issue : My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.