I have more than 20M data in MongoDB and by using java driver I try to get data and plot chart by using JFreeChart.
I have simple main class which reads data from MongoDb,creates dataset and plots chart.When I run the program in PC (3GB Ram,i5 processor) it performs very slowly.In 10 hours it only performs 200K data.Then I try to run the code in IBM server with 24 GB RAM but the performance is same.
This is the command that i run :
java -cp my-program.jar:external1.jar:external2:jar Graph
Shouldn’t it be fast on the server? How could I improve the performance?
I solved the problem.It is not related with the Java, the problem is caused by Jfreechart.
I am sorting data on MongoDB and add data to the XYSeries in order to create dataset.
XYSeries has autoSort field in the constructor and by default it is true. That means when you add new item to the dataset it checks whether or not the items in the series are sorted. By setting it false improves the performance.
Secondly, I setted the notify to false in the add method. If it is not setted as false, then it sends notification to all registered listeners which reduces performance.