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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:10:50+00:00 2026-05-25T19:10:50+00:00

Basically, as the question states… does the order of LINQ functions matter in terms

  • 0

Basically, as the question states… does the order of LINQ functions matter in terms of performance? Obviously the results would have to be identical still…

Example:

myCollection.OrderBy(item => item.CreatedDate).Where(item => item.Code > 3);
myCollection.Where(item => item.Code > 3).OrderBy(item => item.CreatedDate);

Both return me the same results, but are in a different LINQ order. I realize that reordering some items will result in different results, and I’m not concerned about those. What my main concern is in knowing if, in getting the same results, ordering can impact performance. And, not just on the 2 LINQ calls I made (OrderBy, Where), but on any LINQ calls.

  • 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-05-25T19:10:51+00:00Added an answer on May 25, 2026 at 7:10 pm

    It will depend on the LINQ provider in use. For LINQ to Objects, that could certainly make a huge difference. Assume we’ve actually got:

    var query = myCollection.OrderBy(item => item.CreatedDate)
                            .Where(item => item.Code > 3);
    
    var result = query.Last();
    

    That requires the whole collection to be sorted and then filtered. If we had a million items, only one of which had a code greater than 3, we’d be wasting a lot of time ordering results which would be thrown away.

    Compare that with the reversed operation, filtering first:

    var query = myCollection.Where(item => item.Code > 3)
                            .OrderBy(item => item.CreatedDate);
    
    var result = query.Last();
    

    This time we’re only ordering the filtered results, which in the sample case of “just a single item matching the filter” will be a lot more efficient – both in time and space.

    It also could make a difference in whether the query executes correctly or not. Consider:

    var query = myCollection.Where(item => item.Code != 0)
                            .OrderBy(item => 10 / item.Code);
    
    var result = query.Last();
    

    That’s fine – we know we’ll never be dividing by 0. But if we perform the ordering before the filtering, the query will throw an exception.

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

Sidebar

Related Questions

As the question states basically. If you have X-UA-Compatible in both your HTTP headers
Basically as the question states, if I make my services asynchronous does that mean
Basically my question is i have a website which was developed around 3 years
I have a question, which is basically a question on Python template engine capability.
I have a simple question about creating multiple initialisers within an objective-c class. Basically
I would like to be able to basically have a button which allows me
Basically the question is how to get from this: foo_id foo_name 1 A 1
Basically my question is the exact same one as this: Simple client/server, TCP/IP encrypting
Basically the question could more probably be more accurately asked, how do I simply
Basically the question is, Why are NONE of the changes I've been making in

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.