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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T08:39:58+00:00 2026-05-12T08:39:58+00:00

To Set up the scenario, Lets say I have 100000 rows in the table

  • 0

To Set up the scenario, Lets say I have 100000 rows in the table and it grows more and more each day. This queue currently takes over 2 seconds to retrieve only about 40 or 50 rows from the table.

The data in this table are grouped by DateTime references so I start off grouping all the data by DateTime because this is the only equal value to other rows in the table. Each group of rows could be anywhere from 1 row to 5 rows MAX. I then select the grouped rows, pick apart the data and display it out to the user. The problem I can see is that I cause an EXIST and a Group by in the SQL. I must select all 40 rows at once to make the queue faster, but I pick each group out in a FOR loop. So how if any way can I make this queue faster? Its the Laggiest of them all and my users are complaining about the 2 second wait time. Please help.

(from yy in Data_Captured_Type_Militaries
    where yy.DateTime_Added >= DateTime.UtcNow.AddHours(-72)
    (from xx in Data_Captured_Type_Militaries
    where xx.DateTime_Added >= DateTime.UtcNow.AddHours(-72)
    group xx by xx.DateTime_Added into gg
    select gg.Key).Contains(yy.DateTime_Added)
    select new
    {
        yy.Elites,
        yy.DateTime_Added,
        yy.Uid,
        yy.Military_Location,
        yy.Province_ID,
        yy.Time_To_Return
    }).ToList()

What it translates to:

SELECT [t0].[Elites], [t0].[DateTime_Added], [t0].[uid] AS [Uid],[t0].[Military_Location], [t0].[Province_ID], [t0].[Time_To_Return]
FROM [Data_Captured_Type_Military] AS [t0]
WHERE (EXISTS (
    SELECT NULL AS [EMPTY]
    FROM (
        SELECT [t1].[DateTime_Added]
        FROM [Data_Captured_Type_Military] AS [t1]
        WHERE [t1].[DateTime_Added] >= @p0
        GROUP BY [t1].[DateTime_Added]
        ) AS [t2]
    WHERE [t2].[DateTime_Added] = [t0].[DateTime_Added]
    )) AND ([t0].[DateTime_Added] >= @p1)
  • 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-12T08:39:59+00:00Added an answer on May 12, 2026 at 8:39 am

    You sort of explain this, but I still don’t understand what this portion of the query does for you:

    where (from xx in Data_Captured_Type_Militaries
           where xx.DateTime_Added >= DateTime.UtcNow.AddHours(-72)
           group xx by xx.DateTime_Added into gg
           select gg.Key).Contains(yy.DateTime_Added)
    

    This nested query grabs each unique DateTime_Added within the last three days. You then use this to narrow down your outer query by making sure each of those DateTime_Addeds exist in the inner query.

    The outer query is already narrowed down to the most recent three days of DateTime_Addeds, so it looks like the inner query won’t actually do anything to it. I could be wrong, but is the inner query even needed at all?

    If it is, please expand or let me know what I’m not understanding.

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

Sidebar

Related Questions

Lets say I have a set of model classes like this: public class Person
I am having following scenario: I have a table lets say X where fields
I have a scenario where I iterate over a set of rows from a
Lets say i have the following set of interfaces.... public interface IStart { void
Lets say I have some view models set up as follows: public class User
Not sure how to implement this scenario: I have a base class let's say
Present Scenario : I have a set of classes that all take a common
Set content of table ... ViewState[Table1] = Table1; // When remove this line, table
Scenario: I have a fairly generic table (Data), that has an identity column. The
Let's say I have this view model: public class MyModel { [Range(0, 999, ErrorMessage

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.