Re: How to increase the speed of searching in a large database?
- From: "Bjorn Abelli" <bjorn_abelli@xxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 31 Mar 2007 06:06:48 +0200
"joeNOSPAM@xxxxxxx" <joe.weinstein@xxxxxxxxx> wrote...
On Mar 29, 7:49 am, "Ting" <raed...@xxxxxxxxx> 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
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?
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?
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
.
- References:
- How to increase the speed of searching in a large database?
- From: Ting
- Re: How to increase the speed of searching in a large database?
- From: joeNOSPAM@xxxxxxx
- How to increase the speed of searching in a large database?
- Prev by Date: trigger in Derby?
- Next by Date: function in Derby[begginer]
- Previous by thread: Re: How to increase the speed of searching in a large database?
- Next by thread: Apache Derby or Sun JavaDB in J2ME
- Index(es):
Relevant Pages
|
|