By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,737 Members | 1,971 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,737 IT Pros & Developers. It's quick & easy.

curious speed problem with java's resultSet getString

P: n/a
I ran into an interesting "problem" the other day when I was working
on a very simple zip code utility function.

I have a table in Oracle with the following columns: zipcode, state,
latitude, longitude.

My method calculates the distance from a given zipcode to all zipcodes
by doing the following:

1. select zipcode, latitude, longitude from zipcode_table;
2. while rs.next() calc distance
3. append to the string buffer if some simple condition.

Now, I noticed that the dang thing was slow. Like 3000 ms (table is
70K rows and I have a 10mb connection (this is an office lan)).

So I took out everything that was conditional and essentially changed
the method to get everything out of the database and keep appending it
to a string. What happens is that the time count goes like this:

1
2
4
.....70,000 records later...
23
423
424
424
424
425

Did you notice the crazy jump in the middle? This ALWAYS happens to
the last few numbers. I even put in some state restrictions in the
query and it still happens to the last few (sometimes the last 5
sometimes the last 10). And you know what? The offending method seems
to be the resultSet.getString().

This sucks ass because its used all over the place in my application.
How can something like getString() taking so long at the end of the
iteration through the result set?

I await some insight into this seemingly crazed problem.

-sulla
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

"Sulla" <su***@bonzomadrid.com> wrote in message
news:43**************************@posting.google.c om...
I ran into an interesting "problem" the other day when I was working
on a very simple zip code utility function.

I have a table in Oracle with the following columns: zipcode, state,
latitude, longitude.

My method calculates the distance from a given zipcode to all zipcodes
by doing the following:

1. select zipcode, latitude, longitude from zipcode_table;
2. while rs.next() calc distance
3. append to the string buffer if some simple condition.

Now, I noticed that the dang thing was slow. Like 3000 ms (table is
70K rows and I have a 10mb connection (this is an office lan)).

So I took out everything that was conditional and essentially changed
the method to get everything out of the database and keep appending it
to a string. What happens is that the time count goes like this:

1
2
4
....70,000 records later...
23
423
424
424
424
425

Did you notice the crazy jump in the middle? This ALWAYS happens to
the last few numbers. I even put in some state restrictions in the
query and it still happens to the last few (sometimes the last 5
sometimes the last 10). And you know what? The offending method seems
to be the resultSet.getString().

This sucks ass because its used all over the place in my application.
How can something like getString() taking so long at the end of the
iteration through the result set?

I await some insight into this seemingly crazed problem.

-sulla


By appending to a string I hope you do not mean a String object and its +=
operator?

Silvio Bierman
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.