XMLbeans extremely slow

I am working on an application where some XML is formed based on some data in the oracle database. If we use Oracle to return the data back in xml format, it does that in a reasonable amount of time. However creating it using XMLBeans from the data slows down the application tremendously. Here is a comparison

time taken using XMLBeans in millisec = 11483

time taken by using oracle toreturn xml= 640

Now looking at the two times the difference is huge. Is there anything I am missing?

[545 byte] By [kilyasa] at [2007-11-27 7:35:54]
# 1

Just in case someone wants to look at the code to be able to advise if it could be tweaked, here it is

com.test.erm.xmlbeans.v1.holdings.ROWSETDocument rowSetDoc = com.test.erm.xmlbeans.v1.holdings.ROWSETDocument.Factory

.newInstance();

com.test.erm.xmlbeans.v1.holdings.ROWSETDocument.ROWSET rowSet = rowSetDoc.addNewROWSET();

List queryForList = this.jdbcTemplate.queryForList(GET_HOLDINGS, new String[] { portfolios, secTypes }, new int[] {

Types.VARCHAR, Types.VARCHAR });

for (Iterator iter = queryForList.iterator(); iter.hasNext();) {

Map result = (Map) iter.next();

com.test.erm.xmlbeans.v1.holdings.ROWSETDocument.ROWSET.ROW row = rowSet.addNewROW();

row.setPORTFOLIOID((String) result.get("PORTFOLIO"));

row.setCCMSECTYPE((String) result.get("CCMSECTYPE"));

row.setPORTFOLIONAME((String) result.get("PORTFOLIO_NAME"));

row.setPAR(((BigDecimal) result.get("SUM(PAR)")).toString());

row.setMARKETVALUE(((BigDecimal) result.get("SUM(MARKETVALUE)")).toString());

}

return (rowSetDoc.xmlText().replaceAll("hol:ROWSET", "ROWSET"));

kilyasa at 2007-7-12 19:16:32 > top of Java-index,Java Essentials,Java Programming...
# 2

XMLBeans is actaully quite fast as an XML to object mapping system that validates the data against your schema.

JiBX may be a bit faster but it looks like you are receiving a significant amount of XML. JiBX does not validate against you schema by the way. It just ensures that you data matches the binding file you create (which is generally a far weaker specification of your data then a schema)

JiBX call also work in "pull" mode which can have sinificant savings wrt SAX parsers (which I believe XMLBeans uses)

see here for a few more options. Most are not as comprehensive as XMLBeans especially in terms of schema support.

Cheers

matfud

matfuda at 2007-7-12 19:16:32 > top of Java-index,Java Essentials,Java Programming...
# 3
So do you think using one of these options there is a psssibility of getting results comparable to the ones I posted from oracle?
kilyasa at 2007-7-12 19:16:32 > top of Java-index,Java Essentials,Java Programming...
# 4
Possibly.Remember that the cost of the parser is always oing to be in addition to the Oracle overhead.I actaully ment to post a link in there http://java-source.net/open-source/xml-parsersCheersmatfud
matfuda at 2007-7-12 19:16:32 > top of Java-index,Java Essentials,Java Programming...
# 5

> Possibly.

>

> Remember that the cost of the parser is always oing

> to be in addition to the Oracle overhead.

>

> I actaully ment to post a link in there

>

> http://java-source.net/open-source/xml-parsers

>

> Cheers

>

> matfud

if however you look at my original post,

time taken using XMLBeans in millisec = 11483

time taken by using oracle to return xml= 640

The time difference is huge. How faster can the JibX be as compared to XMLBeans, ot JAXB. After all the underlying architecture is more or less the same. Now I am not talking about comparison between XMLBeans and JAXB, its between XMLBeans and generating xml from within Oracle.

kilyasa at 2007-7-12 19:16:32 > top of Java-index,Java Essentials,Java Programming...
# 6

You might also want to time certain parts of the operation.

I have a feeling that the replaceAll you perform at the end is quite expensive.

I can't tell you how much faster the other options are. you'll have to try for yourself. I do know that JiBX has proved faster then XMLBeans for a number of applications I have. How much faster depended on the task. Most code is now using JiBX (although that is primarily for business reasons, not necessarily performance)

matfud

matfuda at 2007-7-12 19:16:32 > top of Java-index,Java Essentials,Java Programming...