• Post Reply Bookmark Topic Watch Topic
  • New Topic

poor desktop project...

 
ankur rathi
Ranch Hand
Posts: 3830
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my desktop project, I am using JDBC. I need to get data from database in aroud all the methods, so I doing the follwing in all those methods: loading class, making connection, getting data, closing connection.

Now the problem is, my project performance is very poor. It is very slow while execution.

What can I do to avoid this situation?

Thanks a lot.
 
steve souza
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You will need to measure to see where your application is slow and tune the slow part. Search this forum and you will see all kinds of suggestions on how to do this.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As an aside, it's a bad idea to spread SQL/JDBC all over your code. You should separate your database access code from the rest of the application, for example using the DAO pattern. If you want to discuss this, the OO forum would be a good place to start a thread on this.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In addition what Ilja suggested.

- You had better use connection pooling for get connection mechanism.
- If you are having performance lack on DB side then you can use stored procedures. It would be faster.
- Check for indices, whether you have necessary indices or not.
- You should remove un-necessary indices to improve the performance if your DB.
- Avoid use of Statement. Use PreparedStatement instead.

Thanks.
[ December 11, 2005: Message edited by: Adeel Ansari ]
 
uj johansson
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

What can I do to avoid this situation?

You could replace yourself with a better programmer . If that's not an option you can stop and think for a while.

Where does your application most likely spend time. Is it maybe expensive to open and close the connection to the database repeatedly? It's likely but no one can know for sure. So you test it right! Have you done that? Have you established what's taking time in your application? That's what you have to do to be able to improve it. You have to know what takes time. You have to find your performance bottleneck.

Your problem may be the result of the so called "don't optimize early" dogma. It says you shouldn't bother at all with efficiency. It says wait until the project is over and then identify the bottleneck. When you remove it your program will be as fast as lightning. Are you influenced by this kind of thinking?

Anyway it never works. Regardless of what the "don't optimize early" crowd told you you're now stuck with inefficient code. The next time listen to real programmers.

PS. Why do you belittle yourself by displaying a track record of your failures? That makes me think maybe you want out. Take the holidays and rethink your future, programming isn't for everyone. Growing magic mushroms in Patagonia may be an option
[ December 31, 2005: Message edited by: uj johansson ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by uj johansson:
Your problem may be the result of the so called "don't optimize early" dogma. It says you shouldn't bother at all with efficiency. It says wait until the project is over and then identify the bottleneck. When you remove it your program will be as fast as lightning.


I don't know a dogma with that name, just a common fairly good practice. And it doesn't say that you should wait until the end of the project, it just says that you shouldn't apply a "performance improvement" until you have proven that you actually have a performance problem, and that the improvement really fixes it.


Anyway it never works. Regardless of what the "don't optimize early" crowd told you you're now stuck with inefficient code. The next time listen to real programmers.


He isn't stuck with it. He just have to find it to remove it. As everyone would have to do - *guessing* just doesn't work.
 
Adam Richards
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another thing to check is connection pooling. Opening & closing connections repeatedly could be one source of poor performance.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand the comments about connection pooling in the context of a simple desktop app that is connecting to a database. What good would a thread pool be versus just hanging on to a connection and reconnecting if it times out?
[ January 09, 2006: Message edited by: Jeff Albrechtsen ]
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeff Albrechtsen:
I don't understand the comments about connection pooling in the context of a simple desktop app that is connecting to a database. What good would a thread pool be versus just hanging on to a connection and reconnecting if it times out?


Well, how is this different from a connection pool of the size one?
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adeel Ansari said:
If you are having performance lack on DB side then you can use stored procedures. It would be faster.

Not necessarily. That would be another case of measuring first what impact a change has, instead of just assuming that the impact would be positive. Not to mention that the use of stored procedures has implications on the design, so that's another tradeoff to be considered.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ilja Preuss:
Well, how is this different from a connection pool of the size one?



"I'm connection pooling my single connection" sounds much more impressive.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!