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 8331389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T02:24:16+00:00 2026-06-09T02:24:16+00:00

I have some slow linq queries and need to optimize them. I have read

  • 0

I have some slow linq queries and need to optimize them. I have read about compiled queries and setting the merge option in NoTracking in my readonly operations.
But I think my problem is that I have too many Includes so the number of joins done in the DB is huge.

context.ExampleEntity
      .Include("A")
      .Include("B")
      .Include("D.E.F")
      .Include("G.H")
      .Include("I.J")
      .Include("K.M")
      .Include("K.N")
      .Include("O.P")
      .Include("Q.R")
      .Where(a => condition1 || complexCondition2)

My doubt is, if I put the Where before the Includes, would this filter ExampleEntity objects before making all the joins?? Im not sure about how linq queries are translated to SQL

  • 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-09T02:24:17+00:00Added an answer on June 9, 2026 at 2:24 am

    “Yes”.
    Each sub-query passes it’s results to the next. Moving the Where first will filter, then perform the includes against a potentially smaller set.

    Whether that makes sense in the context of your specific query is up to you to decide.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently when I come across some slow queries, I have seen this Using sort_union(sourceClass,destinationClass)
I have some data loaded as a np.ndarray and need to convert it to
Edit: solution added. Hi, I currently have some working albeit slow code. It merges
I have some regexes in a Perl script that are correct but slow. I
We have some users which are using lower-CPU powered machines and they're encountering slow
I have seen some real slow build times in a big legacy codebase without
I have some slow internet task to save and load file, I'd like to
I've tried several things... using Variables and Templates, and have made some slow progress.
I have some large csv files (1.5gb each) where I need to replace specific
I have some settings I need in a Javascript file -- servers to connect

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.