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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:06:08+00:00 2026-06-12T09:06:08+00:00

I am making a web app, using ASP.NET. Basically, I need to display data

  • 0

I am making a web app, using ASP.NET. Basically, I need to display data from a SQL Server, which has a billion-row database. When I query something, it often takes a lot of time. For example, I used this codes to query data created from the past week:

DECLARE @CurrentDate as DateTime,
        @PastWeek as DateTime;

SET @CurrentDate = GETDATE();
SET @PastWeek = DATEADD(ww, -1, @CurrentDate);      

SELECT [ID]
      ,[TIMESTAMP]
      ,[USERNAME]
      ,[CLIENTNAME]
      ,[COMMAND]
      ,[PATH]
  FROM [P4D] WHERE TIMESTAMP BETWEEN @CurrentDate AND @PastWeek;

It is still querying after 20 min. I think it takes long because it tests every single row whether it is in the time range or not.

Is it the wrong way to pull data created from pastweek? Or are there any ways making the query statements more efficient?

Thanks!

  • 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-12T09:06:09+00:00Added an answer on June 12, 2026 at 9:06 am

    2 things you need:

    SELECT ID 
          ,TIMESTAMP
          ,USERNAME 
          ,CLIENTNAME 
          ,COMMAND
          ,PATH
      FROM P4D (NOLOCK) WHERE TIMESTAMP BETWEEN @CurrentDate AND @PastWeek; 
    

    (Add a nolock to your query)

    And add a non clustustred index with TIMESTAMP and add the selected columns (ID,USERNAME,CLIENTNAME,COMMAND,PATH) to this index.

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

Sidebar

Related Questions

we are making an web application using some big asp.net web toolkit. At the
I'm making an ASP.NET web forms web app. I've just started with the client
Ok so I'm making a simple web app using the technologies from the topic,
I'm just learning ASP.net and also making a web app for a friend in
I am making a web-app using GlassFish. In this webapp I need to be
I'm making a web app which display a HTML table. The app is written
We recently built a web app using Prototype, making a fair amount of use
I am in the middle of making an app using a PHP web service
i've been making web app's and working with various server side language like php,
I am practicing making a web app which tries to read the user's twitter

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.