I'm seeking some advice on a performance improvement.
I did some profiling on a query that returns 500K rows of data. I
discovered that one method in org.h2.util.DateTimeUtils uses about 25% of
the elapsed time:
public static long getTimeLocalWithoutDst(java.util.Date d) {
Calendar calendar = getCalendar();
return d.getTime() + calendar.get(Calendar.ZONE_OFFSET);
}
I made a modified version of H2 which only calculates
calendar.get(Calendar.ZONE_OFFSET) once per session, and the performance of
my query did improve dramatically.
Here's my code:
private static int zoneOffset = Integer.MIN_VALUE;
public static long getTimeLocalWithoutDst(java.util.Date d) {
if (zoneOffset == Integer.MIN_VALUE) {
Calendar calendar = getCalendar();
zoneOffset = calendar.get(Calendar.ZONE_OFFSET);
}
return d.getTime() + zoneOffset;
}
However I think that this introduces a bug. If the timezone of the computer
changes while H2 is running, then with my 'improvement' H2 would continue
to use the wrong zoneOffset value.
I think it would be acceptable to calculate the zoneOffset value once per
query. The performance gains would be there, but the code would continue to
be correct when the computer's timezone changes.
What do you think about that? Do you have a suggestion how I could do this?
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/h2-database.
For more options, visit https://groups.google.com/d/optout.