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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:32:42+00:00 2026-05-25T01:32:42+00:00

Our company has a Batch Application which runs every day, It does some database

  • 0

Our company has a Batch Application which runs every day, It does some database related jobs mostly, import data into database table from file for example.

There are 20+ tasks defined in that application, each one may depends on other ones or not.
The application execute tasks one by one, the whole application runs in a single thread.

It takes 3~7 hours to finish all the tasks. I think it’s too long, so I think maybe I can improve performance by multi-threading.

I think as there is dependency between tasks, it not good (or it’s not easy) to make tasks run in parallel, but maybe I can use multi-threading to improve performance inside a task.

for example : we have a task defined as “ImportBizData”, which copy data into a database table from a data file(usually contains 100,0000+ rows). I wonder is that worth to use multi-threading?

As I know a little about multi-threading, I hope some one provide some tutorial links on this topic.

  • 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-25T01:32:42+00:00Added an answer on May 25, 2026 at 1:32 am

    Multi-threading will improve your performance but there are a couple of things you need to know:

    1. Each thread needs its own JDBC connection. Connections can’t be shared between threads because each connection is also a transaction.
    2. Upload the data in chunks and commit once in a while to avoid accumulating huge rollback/undo tables.
    3. Cut tasks into several work units where each unit does one job.

    To elaborate the last point: Currently, you have a task that reads a file, parses it, opens a JDBC connection, does some calculations, sends the data to the database, etc.

    What you should do:

    1. One (!) thread to read the file and create “jobs” out of it. Each job should contains a small, but not too small “unit of work”. Push those into a queue
    2. The next thread(s) wait(s) for jobs in the queue and do the calculations. This can happen while the threads in step #1 wait for the slow hard disk to return the new lines of data. The result of this conversion step goes into the next queue
    3. One or more threads to upload the data via JDBC.

    The first and the last threads are pretty slow because they are I/O bound (hard disks are slow and network connections are even worse). Plus inserting data in a database is a very complex task (allocating space, updating indexes, checking foreign keys)

    Using different worker threads gives you lots of advantages:

    1. It’s easy to test each thread separately. Since they don’t share data, you need no synchronization. The queues will do that for you
    2. You can quickly change the number of threads for each step to tweak performance
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our company has a product which relies on local database to work (it allows
Our company is developing a new application, which has a somewhat large business data
Our company has a fairly large ASP.NET web application. The app is already broken
My company has a ClickOnce application that has been in use with our customers
I'm in a position where our company has a database search service that is
I've built a CMS for our company which has a huge number of functions,
Our company has a very large public Java API which is currently being released
Our company has a web service which I want to send XML files (stored
We are seeing a problem with our company's application that has me very confused
Our company has a point of sale system with many extras, such as ordering

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.