Uploaded image for project: 'jBPM'
  1. jBPM
  2. JBPM-3430

JobSession.getFirstUnownedDueJob query inefficient

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • jBPM 3.2.12
    • jBPM 3.2.9
    • Runtime Engine
    • None

      Regarding the HQL query that is used to calculate nextDueDate in DispatcherThread, JobSession.getFirstUnownedDueJob, I just checked with a Hibernate expert and it could indeed be the case that this query returns the bigger part of the JBPM_JOB table.

      The HQL query is defined like this:

        <query name="JobSession.getFirstUnownedDueJob">
          <![CDATA[
            select job
            from org.jbpm.job.Job job
            where job.lockOwner is null
            and job.retries > 0
            and job.isSuspended = false
            order by job.dueDate asc
          ]]>
        </query>
      

      and the result is handled that way:

      return (Job) query.setMaxResults(1).uniqueResult();
      

      Hibernate can issue a request that returns all records from the DB, and then just restrict the result to a single row. To prevent this potentially expensive DB call, the 'correct' way would be to add further restrictions to the HQL.

            marco.rietveld Marco Rietveld (Inactive)
            marco.rietveld Marco Rietveld (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: