Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / March 2007

Tip: Looking for answers? Try searching our database.

How to increase the speed of searching in a large database?

Thread view: 
Ting - 29 Mar 2007 15:49 GMT
Hi all,

I have a very big database that contains one million rows in it. After
an SQL command is executed and the results are assigned to a ResultSet
variable, it takes a long time to print the result out. My code looks
like something similar to this:

ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
   System.out.println(rs.getString(1));
}

And this would take nearly one minute to print the resultset out.

Is there anyway that I can make it faster?

Thanks!
Ting
joeNOSPAM@BEA.com - 29 Mar 2007 16:44 GMT
> Hi all,
>
[quoted text clipped - 15 lines]
> Thanks!
> Ting

This is nothing to do with Java, it has to do with
the DBMS, the query, and what has been done to
optimize indexes in the DBMS, and whether you should
be doing the query at all. How many rows are you
selecting?

Joe Weinstein at BEA Systems
Bjorn Abelli - 31 Mar 2007 05:06 GMT
"joeNOSPAM@BEA.com" <joe.weinstein@gmail.com> wrote...

>> I have a very big database that contains one million rows in it. After
>> an SQL command is executed and the results are assigned to a ResultSet
[quoted text clipped - 16 lines]
> be doing the query at all. How many rows are you
> selecting?

There is though one thing more connected with Java that *could* speed up
things for you as well, and that is to use a CachedRowSet instead of a
ResultSet.

If you can use it, and if that can increase speed in your case, depends on
which DB you're using, which driver you're using, and how the state of the
network is. In some cases it can speed up things simply as it can minimize
the network traffic, provided the DB/driver can fetch the result in one
single batch. If the network is a bottleneck, the CachedRowSet can then be
useful.

But I'd go with Joe, to check out what you can do on the DBMS first.

/// Bjorn A


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.