Its impossible to say from what you have described. Premature Optimization is a sin.
If you consider the data from the database as an opaque object, it would seem that a simple caching scheme would address any performance issues if you have them. But first, do you really have a performance problem on the Java side? Have you properly setup the indexes for your RDMBS?
Am I correct in assuming that the entire XML document parsed into a DOM is not a burden on memory?
If so you can use a one-time parsing step to create a HashMap in which the values are references to the XML Elements you need to retrieve. This is fast and still preserves the XML structure of the associated data.
DOM parsers uses up too much memory as it stores the entire XML document in memory as a Document object. If you end up doing the same by maintaining the XML but as a Map instance, I dont see any significant advantage except for the fact hat retrieval of associated values could be faster in the case of a Map as it would not require you to iterate through the entire DOM tree. It again would depend on the structure of the XML and the how the map is organized?
Author and all-around good cowpoke
Joined: Mar 22, 2000
I am using a SAX parser to parse the document and while parsing i have kept the elements in a hashmap.
DOM does use alot of memory but the decision depends on how big the document is, the exact access you need, etc etc. If you have it working - don't change anything just to be chasing a possibly illusionary performance gain.
With SAX, watch out for the characters() method - you don't always get the full text in a single call.