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

Query-performance question

Atul Mishra
Ranch Hand

Joined: Jun 08, 2006
Posts: 140
I have a requirement to do a select * from a table to output all records based on one input.
The query will be select *[29 fields] from xtable where xfield like ''.

Now this can return anywhere upto 45000 records.

What can I do to maximize the performace of this ? Is using a preparedstatement good idea ? Any thoughts appreciated.

Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

A prepared statement is useful when you want to send a similiar query to the database engine where the query is the same except that there are different parameters. Here, it sounds like you have one query that is run in which case I don't think that a prepared statement would help.

What do you do with the 45,000 records?

What about a stored procedure which runs on the server-side? This would keep the records from having to come across to the client-side.

If you're viewing the records in a JTable, there's the ResultSetTableModel. I believe that a ResultSetTableModel just brings across the records as necessary to be viewed a screenful at-a-time.

Would it help to use a LIMIT clause and bring the records over, let's say 100 at-a-time? Only as needed.

sathish kumar
Ranch Hand

Joined: Feb 14, 2007
Posts: 47
Why a batch for processing 45,000 records. Write a Stored procedure, invoke it in a Java main method.
I agree. Here's the link:
subject: Query-performance question
It's not a secret anymore!