4 Replies Latest reply on Jul 26, 2002 10:59 AM by jcasp

    read-ahead & transaction performance tuning

    jcasp

      I'm having a problem convincing JBoss to optimize it's query usage when using the read-ahead and transaction options for performance tuning.

      Despite following the examples in the Quickstart guide and the latest JBossCMP docs regarding the transaction attributes and the read-ahead strategy, I'm continuing to generate N*M +1 queries when loading a group of entities using commit-option B.
      Each entity N is having M (M=number of fields in the bean) queries called on it, since JBoss is throwing away the entity data between abstract accessor calls.

      I set the transaction attributes of my session bean methods to RequiresNew. These session beans call the field accessors of the entity beans. Standard, basic design pattern here. So I don't understand why all of these queries are still being generated. The entity bean accessor calls should be inside a transaction, right?

      When I set the commit option to 'A', the queries are reduced to N+1 for the first session bean method invocation, then 1 query for subsequent invocations of the same method. This caching behavior is what I expect, although the initial N+1 is unexpected, since I have the read-ahead strategy set to 'onfind' with a page-size of 10:

      ...
      <query-method>
      <method-name>findByStatus</method-name>
      <method-params>...</method-params>
      </query-method>
      <declared-sql> ...</declared-sql>
      <read-ahead>
      on-find
      <page-size>10</page-size>
      <eager-load-group>basic</eager-load-group>
      </read-ahead>

      The 'basic' eager load group is being followed, as the query printed to the
      server.log shows only the fields mentioned in that load-group in the SELECT
      statement.

      Any idea why JBoss seems to be ignoring the read-ahead strategy and/or the transaction setting of 'RequiresNew' but not the load group?

      I'm using Branch_3_0 from CVS, checked out a few days ago.

      Thanks in advance for any help with this.

        • 1. Re: read-ahead & transaction performance tuning
          jcasp

          Am I correct in thinking that when a session bean method has the transaction attribute 'RequiresNew' is called by a client (a servlet, in my case), that transaction is valid for all calls to entity beans made within that method?
          e.g.,
          <assembly-descriptor>
          <container-transaction>

          <ejb-name>JobManagerBean</ejb-name>
          <method-name>getJobsByOrderDate</method-name>

          <trans-attribute>RequiresNew</trans-attribute>
          </container-transaction>
          </assembly-descriptor>

          the session bean method 'getJobsByOrderDate' which
          1) calls an entity finder
          2) iterates through the Collection of entities returned
          3) returns a value object Collection to the caller
          should wrap all the entity accessor calls in a single transaction, right?
          apparantly, I'm just not getting something here.
          Justin

          • 2. Re: read-ahead & transaction performance tuning
            dsundstrom

            Does it work with Required.

            • 3. Re: read-ahead & transaction performance tuning
              jcasp

              No.
              I guess that's expected, because I didn't have any transaction attributes specified until RequiresNew. I remember reading that 'Required' is the default when unspecified.

              • 4. Re: read-ahead & transaction performance tuning
                jcasp

                bump