Redundant queries in JBossCMP
pazu Apr 8, 2002 1:24 PM[This is about JBoss HEAD 3.0.0beta2(200203221637)]
Hello, folks. I noticed my last post about JBossCMP performance has gone unanswered. Alright, I've solved most of my problems by now.
Anyway, it seems there is still a problem with JBossCMP. I turned on-find read-ahead for all my entities so I can speed up some findAll() queries. However, the result was not what I expected. I get the following in the log file:
DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCJBossQLQuery.Divisao.findAll] Executing SQL: SELECT t0_o.DIVISAO_ID, t0_o.DESCRICAO, t0_o.FILIAL_ID, t0_o.DATASINC FROM DIVISOES t0_o ORDER BY t0_o.DESCRICAO ASC
And I thought: "Great, my whole entity is being loaded on the finder command. There is no need for further SQL". It seems I'm wrong, because the 5 or so following log lines are like this one:
DEBUG [org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.Divisao] Executing SQL: SELECT DIVISAO_ID,DESCRICAO, FILIAL_ID, DATASINC FROM DIVISOES WHERE (DIVISAO_ID=?) OR (DIVISAO_ID=?) OR (DIVISAO_ID=?) OR (DIVISAO_ID=?) OR (DIVISAO_ID=?) OR (DIVISAO_ID=?) OR (DIVISAO_ID=?) OR (DIVISAO_ID=?) OR (DIVISAO_ID=?)
And now I'm thinking: why JBoss is issuing all these individual load commands since all my entities were already loaded on the finder command? Can I do something to prevent this? My goal is to tune DB acess to the maximum permitted. I don't want JBoss issuing any unecessary queries.
This entity I discuss here my simplest entity. I used it just to have a small, comprehensible example. I've much larger entities where these extra SQL queries are quite a hit on performance.
Just te reaffirm: DIVISAO_ID, DESCRICAO, FILIAL_ID and DATASINC are fields from the Divisao CMP Entity bean. All of them. There aren't any more fields.
Here is the findAll() JBoss-QL: "SELECT OBJECT(o) FROM Divisao o ORDER BY o.descricao"
My standardjbosscmp-jdbc.xml is configured with <read-ahead>on-find</read-ahead>. Everything else should be pretty much standard values. Any hints?
I'm even thinking about tinkering in the jbosscmp source code if I get some assistance. Dain, could you provide me with some info to start hacking there?