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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:15:28+00:00 2026-05-16T05:15:28+00:00

Need to query a database for 12 million rows, process this data and then

  • 0

Need to query a database for 12 million rows, process this data and then insert the filtered data into another database.

I can’t just do a SELECT * from the database for obvious reasons – far too much data would be returned for my program to handle, and also this is a live database (customer order details) and I can’t have the database crawl to a halt for 10 minutes while it runs my query.

I’m looking for inspiration on how to write this program. I have to process each row. I was thinking it might be best to get a count on the rows. Then grab X at a time, wait for Y seconds, and repeat, until the dataset is complete. This way I’m not overloading the database, and since X will be sufficiently small, will run nicely in memmory.

Other suggestions or feedback ?

  • 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-16T05:15:28+00:00Added an answer on May 16, 2026 at 5:15 am

    A flat file or a snapshot are both ideal.

    If a flat file does not suit or you do not have access to snapshots theny you could use a sequential id field or create a sequential id in a temp table and then iterate using that.

    Something like

    @max_id = 0
    
    while exists (select * from table where seq_id > @max_id)
        select top n * from table where seq_id > @max_id order by seq_id
        ... process...
        set @max_id = @max seq_id from the last lot
    end
    

    If there is no sequential id then you can create a temp table that holds the order like

    insert into some_temp_table 
    select unique_id from table order by your_ordering_scheme
    

    then process like this

    ... do something with top n from table join some_temp_table on unique_id ...
    delete top n from some_temp_table
    

    this way temp_table holds the record identifiers that still need to be processed.

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

Sidebar

Ask A Question

Stats

  • Questions 523k
  • Answers 523k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Record(&r) and Record &r are identical type declarations. I don't… May 16, 2026 at 9:33 pm
  • Editorial Team
    Editorial Team added an answer I think you'll have to create the directory /usr/local/rvm and… May 16, 2026 at 9:33 pm
  • Editorial Team
    Editorial Team added an answer I'm guessing you're using IE browser. If so IE does… May 16, 2026 at 9:33 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have a SQL 2000 database with around 10 million rows and I need
I am working with a large amount of data: 6 million rows. I need
I have a relatively large database tables (just under a million rows) that has
If you had a fairly large amount of data (say a million rows) that
I have a database of names of people that has (currently) 35 million rows.
This is for Entity Framework for .NET 3.5: I have the need to query
I need a real DBA's opinion. Postgres 8.3 takes 200 ms to execute this
What is a good data structure for storing phone numbers in database fields? I'm
I need to store a large table (several millions or rows) that contains a
I am using JDBC to query a MySQL database for specific records from two

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.