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

  • Home
  • SEARCH
  • 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 6099535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:17:03+00:00 2026-05-23T13:17:03+00:00

I’ve a semi complex LINQ query that is running very slow. I do not

  • 0

I’ve a semi complex LINQ query that is running very slow. I do not believe it is using sub queries. I’ve tried to use logging and only see one query generated. the code is similar to the following:

dc.defferedloadingenabled = false
dc.objecttrackingenabled = false

dataloadoptions dlo = new dataloadoptions
dlo.loadwith<MyQuestion>(q => q.lotsofresponses)
dc.LoadOptions = dlo

IQuerayable<Question> questions = dc.questions.where( q => q.ParentId == specificID).orderBy(q => q.Rank);

foreach (question in questions)
{
}

Need help on how to speed this up. I believe I’m using the best practices.

Below is the SQL generated. I removed the actual key and column names. The count(*) looks odd to me.

SELECT [t0].[QId], [t0].[SId], [t0].[Tp], [t0].[St], [t0].[OL], [t0].[Is], [t0].[Tbl], [t0].[IsL], [t0].[Priority], [t1].[ResponseId], [t1].[QId] AS [QId2], [t1].[UId], [t1].[AN], [t1].[AT], (
    SELECT COUNT(*)
    FROM [dbo].[Responses] AS [t2]
    WHERE [t2].[QId] = [t0].[QId]
    ) AS [value]
FROM [dbo].[Questions] AS [t0]
LEFT OUTER JOIN [dbo].[Responses] AS [t1] ON [t1].[QuestionId] = [t0].[QuestionId]
WHERE [t0].[SurveyId] = @p0
ORDER BY [t0].[Priority], [t0].[QId], [t1].[ResponseId]
  • 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-23T13:17:04+00:00Added an answer on May 23, 2026 at 1:17 pm

    Since you’ve captured the query by logging, take it to SqlStudio and examine the execution plan.

    • You should not see TableScan. If you see this, add a primary key to the table.
    • You should not see ClusteredIndexScan on the LotsOfResponses table. If you see this, add an index on the foreign key column of the LotsOfResponses table.
    • You should see ClusteredIndexSeek or IndexSeek on the Questions table. If you don’t see this, make Questions.ParentId into a Primary Key or add an index on it (whichever is most appropriate).

    Also, run the query with

    SET STATISTICS IO ON 
    SET STATISTICS TIME ON
    

    and check the messages tab for performance metrics.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
Seemingly simple, but I cannot find anything relevant on the web. What is the

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.