> On 10 Jun 2017, at 5:37, Steven Grimm <[email protected]> wrote:
[…]
I notice that you're declaring your ResultSet variable inside the loop, which
means that you create and destroy it frequently. I've been told that this is a
pattern that the GC has trouble keeping up with (although that was around the
Java 5 era), so you might be seeing the effects of memory churn in your client
instead of in the database.
I modified your function to not do that anymore, does that make a difference?
Note; the long variables are scalar instead of objects. I don't think they need
the same treatment, but it can't hurt.
> private static void logTime(String name, PreparedStatement stmt) throws
> SQLException {
> StringBuilder out = new StringBuilder(String.format("%-22s", name));
> ResultSet rs;
> long startTime, endTime;
>
> for (int i = 0; i< 20; i++) {
> startTime = System.currentTimeMillis();
> rs = stmt.executeQuery();
> while (rs.next()) {
> rs.getString(1);
> }
> endTime = System.currentTimeMillis();
> rs.close();
>
> out.append(String.format(" %3d", endTime - startTime));
> }
>
> stmt.close();
>
> System.out.println(out);
> }
Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.
--
Sent via pgsql-general mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general