findColumn performance
"Alex Burgel" <[email protected]> Mon, 6 Oct 2008 16:36:32 -0700
| Newsgroups | gmane.comp.db.mysql.java |
|---|---|
| Message-ID | <FA7AD9F87960BD4FA9F706E5B592E2B601DABD5B@ex-be-007-sfo.shared.themessagecenter.com> |
ResultSetImpl.findColumn(String) uses a TreeMap with a comparator to find the correct column number. For big result sets with a lot of columns, this can be a bit of a bottleneck because the comparator must lower case the column names in the map for each lookup. I have been profiling a very db intensive portion of my app and I see findColumn as a hotspot. I use hibernate which gets columns by name, rather than index. I know thats not the most efficient way. For these cases, i was thinking it will be much faster to lower case all the column names before putting them in the map. and then lower case the key before you do a lookup on the map. you can even use a hashmap in this case which will give you a o(1) lookup time instead of o(log n). there will be a greater up front cost, tho i think that will be negligble. has anyone looked into this? i wanted to put this out there before i attempted a patch. --alex -- MySQL Java Mailing List For list archives: http://lists.mysql.com/java To unsubscribe: http://lists.mysql.com/[email protected]