-
1. Re: ABOUT CMP peformance
adrian.brock Oct 25, 2002 7:54 AM (in response to mikel)You probably want to buy Dain's book so you get
a better understanding of what is going on.
The short answer is you are probably starting a
new a transaction for every operation?
A web search on "session facade" should explain this.
Also, look at commit-option A, explained in
the free getting started docs (if JBoss has exclusive
access to the database).
Regards,
Adrian -
2. Re: ABOUT CMP peformance
dokomesiter Oct 30, 2002 9:52 PM (in response to mikel)Bought Dain's book, read it, yet...
That a transaction may force persistence is one thing, but the amount of SQL generated is enormous, for example
1. Add a record to a table (using the jboss autonumber for id)
This generates 4 separate SQL calls
SELECT COUNT(*) FROM fact WHERE id=?
INSERT INTO fact (id, members, measure, application, factTable)
VALUES (?, ?, ?, ?, ?)
UPDATE autonumber SET val=? WHERE name=?
UPDATE fact SET factTable=? WHERE id=?
when 1
INSERT INTO fact (id, members, measure, application, factTable)
and caching autonumber seem very possible
Actually, for some dbms such as mysql it could even optimize this
further and generate a single insert for multiple records, ie
INSERT INTO tbl (var1,var1)
VALUES (?,?)
, (?,?)
, (?,?)
but at this point just an "add" when we tell it to "add" instead of
"ok, let me search two tables" would be a huge improvement
2. CMR if a field is a relationship field, rather than generating a join
CMP typically generates a separate select call per record
For example something that should generate a join like
SELECT a.name, b.address FROM tb1 a, tbl2 b WHERE b.id=a.bid
where the CMP fields are defined (in the java/xml/etc.) like
String getName() // CMP
BType getB() // CMR
does not generate 1 SQL statement, instead it generate hundreds or
thousands of SQL calls to generate the join by rescanning the joined
table for the CMR field, ie
SELECT name, bid from tb1
SELECT address from tbl2 where id=?
SELECT address from tbl2 where id=?
SELECT address from tbl2 where id=?
If CMP optimization doesn't optimize much when CMR is used,
and gemstone is back-level JDK1.3, what are the consumer choices here?
We're at the unfortunate stage where everything is working (CMP, CMR, switching DBMSs, etc.) yet debating re-writing the entire persistence layer ourselves (the test cases indicate a huge performance gain doing so)
Thanks -
3. Re: ABOUT CMP peformance
dokomesiter Oct 31, 2002 8:37 AM (in response to mikel)Oops, forgot to include the relevant parts of the JBoss documentation, the footnote on page 58 of the book:
“It's actually worse than this. JBossCMP executes each of these queries three times; once for each cmp-field that is accessed. This is because the preloaded values are discarded between the cmp-field accessor calls.”
So how do we enable any sort of caching? Multiple SQL calls for every single record when a single join should be used is not optimal (heck, it isn't even "caching")
And
<commit-option>A</commit-option>
doesn't seem to help the CMR case
Thanks,