I have a database containing employee information. I have 4000 employees. Each employee has an unique identification number.
I try to fetch employee information for each employee from the database using a python script. For 1 employee, the execution time for fetching info is 1 seconds. For 4000 employees, it makes 4000
seconds (67 minutes, who would like to wait that long?).
The employee infos should be stored in a dictionary, in the following format:
infos = {"ID1": ["info for employee 1"], "ID2": ["info for employee 2"], ... }
I'm thinking of doing the following to reduce the execution time:
- Get employee id numbers
- Divide the id numbers into 10 groups
- Start 10 threads simultaneously
- Make each thread use 1 of 10 employee id groups and fetch those employees' info from database into separate dictionaries
- In the end, combine those 10 dictionaries
Is it possible? Would this method reduce the execution time 10 times?