• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

poor performance reading webservice and insert database

 
Anderson Daniel Gomes
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello,

I have one application swing that reading one table, query one webservice and after that insert in another table.
But today performance is very poor because I do this row by row.

How I could to improve performance to this scenery.

thanks
Daniel
 
fred rosenberger
lowercase baba
Bartender
Posts: 12149
31
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you know that the poor performance is caused by inserting row-by-row?
 
Anderson Daniel Gomes
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
because I get more time to insert than to query the webservice.
I think if I do queue to query webservice to don´t wait the database the application will be better, but I don´t know how do that yet
 
fred rosenberger
lowercase baba
Bartender
Posts: 12149
31
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So my point is that unless you have specific metrics showing exactly what it taking the most time, any attempts to optimize is pointless. Have you run a profiler that shows it is the inserts that are taking the most time, and not the web service call (for example)? Perhaps you have, in which case great!!

It's hard to give you specific advice without seeing you code - and please don't post hundreds of lines showing us. A short, self contained, correct example is what we prefer (see this).

If I am reading your second post correctly, you are asking how to make a bunch of webservice calls, queue the results, and then have a separate thread process them off and insert to the database?
 
Anderson Daniel Gomes
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry By bad english !

here the code the get data from database as pages:



code that read the webservice and insert on database:
parameter service is only parameter to webservice like as login and password
parameter p is the values that change to query webservice



Let me try to explain better my point, I think that the access the webservice and insert is not so bad, but if make I multithread could be better, don´t it ?
the problem is that I don´t know how do or if is realy better !

best regards !!
 
fred rosenberger
lowercase baba
Bartender
Posts: 12149
31
Chrome Java Linux
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anderson Daniel Gomes wrote: I think that the access the web service and insert is not so bad, but if make I multithread could be better, don´t it ?
the problem is that I don´t know how do or if is realy better !

So that goes back to my first point. You don't have any empirical evidence for where the slowdown is - you're just guessing. The first rule of optimization is to not waste time optimizing anything until you know where the slowdown is.

Further...many people don't realize that multi-threading is not a panacea. There is a cost to making an application multi-threaded. You now need to have something controlling and managing those threads. While the manager is running, you can't do anything else. Granted, it isn't much time, but there is some. And let's not forget about the complexity it adds to your program, making it much harder to debug and maintain.

So...if your code is spending all its time waiting for the return of the web service call, making it multi-threaded won't help. Each thread still has to wait for a response, and if you hammer the server with requests, it may take it LONGER to return each one over doing it sequentially.

If your code has to wait one second for the web service calls to get their response, and your database insert is taking a millisecond...it's probably a waste of time trying to optimize your database inserts to take less time - you'll still be waiting for the web service to return.
 
Anderson Daniel Gomes
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, I understand... so,thanks by your help !
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd say that it might be possible to speed things up by doing them in batches. It would mean modifying the webservice and/or the DAO so that they would support processing more than one item/record per call, and it sounds like a lot of work.

Even if such change is achievable for you, you should try to estimate the potential savings by eg. measuring the time the webservice processing takes and comparing it with the network roundtrip time.
 
Anderson Daniel Gomes
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I agree that could make insert as batch could give more performance, I´ll think how I can do this !!

I´ll measuring the time of the webservice and the database to have an idea better and know if is possible get more performance !

thanks !
 
Winston Gutkowski
Bartender
Pie
Posts: 10430
63
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anderson Daniel Gomes wrote:I´ll measuring the time of the webservice and the database to have an idea better and know if is possible get more performance !

But don't change anything unless you can prove that it's worth the effort.

Winston
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic