【发布时间】:2016-04-10 15:46:36
【问题描述】:
我们有以下逻辑 - 从数据库中获取数据并将数据写入
1.平面文件
2.Excel文件
3.Zip文件
4.将 ZIP 传输到 FTP
现在我已经编写了一个程序,它运行良好,但我正在考虑通过 MyThreading 或任何其他方式来提高性能
任何人都可以提出想法。
请查找程序结构:
//method to get all data from database
Vector plans=getOnlyPlanId(); // here i will have 5000 planIds
for(i=0;i<500;i++) // loop for plans/500 -----Point number 1
{
String FiveHundresplanId="500 plans";
//i will makes first 500 plansid and send to database to get data....
Vector PlansData=getAllPlansData(FiveHundresplanId); // here i will get data like 21000+ for first 500 plans
//now , loop for 21000 planData
for(i=0;i<plansdata.size;i++)
{
createFlatFile();
createExcelFile();
createZipOfallFiles();
TrasferZipToFTP();
}
}
我在想,我在向 FlatFile、ExcelFile、ZipFile 写入数据的同时可以要求程序执行我的 (Point number1) 500 个计划查询并为接下来的 500 个计划做好准备,所以只要我们将文件传输到 FTP 我们不需要等待执行下一个 500 计划查询。
这会提高性能吗?
如果是的话,有什么想法可以做到吗?
【问题讨论】:
标签: java database multithreading performance batch-processing