File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and the fly likes Tips for Better JDBC querying Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Tips for Better JDBC querying" Watch "Tips for Better JDBC querying" New topic

Tips for Better JDBC querying

Jack Daniel
Ranch Hand

Joined: Jun 15, 2002
Posts: 163
Hi e'body,

Well, I am in a project where you query {DB2} database tables, having more than a million records;

So what do you guys think is a better way to handle such a situation??

I anyway use DataSource Connection Pooling;
any tips on optimized ways of querying is greatly appreciated..!!

looking forward to hear from you guys.. i know, you guys have great ideas..
Thanks :-)

PS: if anyone can forward links where i can find optimized ways of querying, that would be great
[ September 13, 2004: Message edited by: Bear Bibeault ]
Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30361

The most important thing is well though out indexes. Also, run your queries through db2 explain to find optimizations.

[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
but indexes doesn't help in full table scan. i think we should avoid full table scans in these kind of situations.


- indexes help in query
- indexes may suck when there is lots of updates

so be careful
Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30361

I agree with what you said. As Prashant's table has millions of rows, a full table scan is unlikely to be occuring.
It is sorta covered in the JavaRanch Style Guide.
subject: Tips for Better JDBC querying