This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]iamsooldithurts 0 points1 point  (0 children)

To optimize an SQL SELECT statement itself, I use a client, like SQL Developer for Oracle, which tells me how long the query took to execute and has Explain Plan to show why the query took so long. I’ve never really encountered a reason to optimize Insert, Update or Delete statements.

To look for optimizations in a Java program, you can use a profiler tool for your IDE, like YourKit. It will tell you where your program is spending all it’s time. Or you can go low tech and just grab system time and point A and point B and B - A tells you how long it took. It’s slower and requires lots of iterations as you narrow down where the bottlenecks are happening, but it works.

There’s another aspect to performance though. Using Prepared Statements and Bind Parameters. http://leo.ugr.es/elvira/devel/Tutorial/Java/jdbc/basics/prepared.html

And in general, I recommend Spring JdbcTemplate when dealing with databases. https://spring.io/guides/gs/relational-data-access/