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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T17:23:14+00:00 2026-05-26T17:23:14+00:00

We have a giant SQL Server 2005 database (75GB) which basically is just data

  • 0

We have a giant SQL Server 2005 database (75GB) which basically is just data in one table with sales values (per day, store and article). We want to make place by adding up the sales value per week for every record older than a year (still grouped per store and article). So in theory for data older than a year we can then remove 6 out 7 records.

Writing a procedure to do this is not really a problem but it runs like forever. So I was looking for a strategy that could make this run in a reasonable amount of time.

To give you an idea: running SELECT count(*) ran for over 4 minutes

We do have a few indexes (on date (clustered) and on the store, article and date combination). Adding any more indexes also takes like forever.

Anyone has got a good strategy on how to perform this task? Any suggestions on TSQL methods which perform better than the basic DML statements?

  • 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-26T17:23:14+00:00Added an answer on May 26, 2026 at 5:23 pm

    If You use SQL Server 2005 Enterprise Edition, You should consider using partitioning feature. Benefits:

    • by partitioning your data on date column, queries will run much faster because SQL Server will access only specific partition; this way you can run your day->week procedure on date range and it will run much faster (and run multiple procedures on different date ranges at the same time)
    • if You want to keep your daily data, just move old partitions to slower storage (hard disk)
    • your procedure should prepare weekly data in new table and then switch partitions – it is much faster than delete daily data and insert weekly data

    If You don’t use Enterprise Edition, use this link to see partitioning (sharding or horizontal partitioning) capabilities not based on SQL Server 2005 partitioning feature.

    For stored procedure optimization:

    • reevaluate current indexes for your SP
    • consider daily->week procedure to run on date ranges, for instance, year by year or month by month – running procedure on whole history will be a lot of work for SQL Server and underlying hardware
    • probably the best way is: following previous item about date ranges, create new table based on old weekly data and recent daily data then create indexes and then in one transaction drop original table and use sp_rename to put old table instead of new one – rename is almost instant so no one will notice the delay if that is important
    • consider dropping indexes on target table because inserts will be much slower with it – only if You are working on the original table (delete + insert)

    Off-topic hint: if using Enterprise Edition, consider compressing your table since SQL Server 2005 is usually good at compression of fact tables – you will probably gain both performance and disk space if You have enough CPU power.

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

Sidebar

Related Questions

First a little introduction. We have an SQL Server Express 2008 database, which schema
I have two databases on the same SQL Server: Database A table 1 table
I have a winform C# application which uses sql server 2005 express. I am
I am using SQL Server Express 2005. I have only a single database to
I have a SQL Server 2005 database that I'm trying to access as a
Our program ships with an SQL Server 2005 database and SQL Server 2005 Express.
I have a requirement in SQL Server 2008 in development database Only DBA's (
We have set up a logshipping scenairo on 2 Sql Server 2005 machines. The
my c#.net winforms application which uses sql server 2005 express , would be run
I have two Microsoft SQL Server 2000 databases, and a stored procedure on one

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.