Re: [GENERAL] Inconsistent performance with LIKE and bind variable onlong-lived connection
От | Alban Hertroys |
---|---|
Тема | Re: [GENERAL] Inconsistent performance with LIKE and bind variable onlong-lived connection |
Дата | |
Msg-id | 65641F01-5BC1-4EDF-AA1F-69796D6EFC83@gmail.com обсуждение исходный текст |
Ответ на | [GENERAL] Inconsistent performance with LIKE and bind variable on long-lived connection (Steven Grimm <sgrimm@thesegovia.com>) |
Ответы |
Re: [GENERAL] Inconsistent performance with LIKE and bind variable onlong-lived connection
|
Список | pgsql-general |
> On 10 Jun 2017, at 5:37, Steven Grimm <sgrimm@thesegovia.com> 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 Java5 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.
В списке pgsql-general по дате отправления: