I have a table with almost 60000 data in it and I am running a select statement using myBatis mapper files, after analysing the code in debug mode I found that the data from the database was coming into DataSource fairly quickly, it was taking time while storing it in the List.
Driver Code.
Map<Long, Some_Custom_Class> mp = new HashMap<>();
List<Some_Custom_Class> myVar = selectAllDataFromTable();
if(myVar != null){
for(Some_Custom_Class cs: myVar){
mp.put(cs.getId(), cs)
}
}
Mapper File
<select id="selectAllDataFromTable" resultMap="VariableMap">
select * from myTable
</select>
<resultMap id="VariableMap" type="myPackage.Some_Custom_Class">
<id property="VariableID" column="variable_id" />
<id property="SecondID" column="Second_ID" />
<id property="Tag" column="tag" />
</resultMap>
I need to speed up the data insertion process in the list, is there any way to do it? I know a way that but I am not sure if it is correct. The way is by using threads and maybe having 2-4views and letting those threads access those views in some range let's say 0-10000 and so on. The for loop doesn't take much time to loop through 60000 data, but speeding that up will be a secondary task. My goal is to populate the list in the fastest way possible, can someone help me with that.
CodePudding user response:
