You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
We are investigating some massive index scan on a spring-batch database and we noticed that these queries COUNT_STEP_EXECUTIONS and COUNT_STEP_EXECUTIONS in JdbcStepExecutionDao can be optimized.
In fact, these queries seems to use a useless sub-query, and so, will scan the BATCH_JOB_EXECUTION table twice.
These queries can be re-written like below without any impact on the current behavior.
COUNT_STEP_EXECUTIONS :
current query :
SELECTCOUNT(*)
from %PREFIX%JOB_EXECUTION JE, %PREFIX%STEP_EXECUTION SE
whereSE.JOB_EXECUTION_IDin (SELECT JOB_EXECUTION_ID from %PREFIX%JOB_EXECUTION whereJE.JOB_INSTANCE_ID= ?)
andSE.JOB_EXECUTION_ID=JE.JOB_EXECUTION_IDandSE.STEP_NAME= ?
enhanced query :
SELECTCOUNT(*)
from %PREFIX%JOB_EXECUTION JE, %PREFIX%STEP_EXECUTION SE
whereSE.JOB_EXECUTION_ID=JE.JOB_EXECUTION_IDandJE.JOB_INSTANCE_ID= ?
andSE.STEP_NAME= ?
…ao use a useless sub-query, and so, will scan the BATCH_JOB_EXECUTION table twice
The fix is to remove the sub-query and filter on the JOB_INSTANCE_ID of the BATCH_JOB_EXECUTION join table
Fixspring-projects#4017
While reviewing this PR, I noticed that these optimizations have been already applied in previous PRs: #3997 and #3876.
Those are available in 5.0.0-M1 and 4.3.5. Thank you for your contribution anyway!
Hello,
We are investigating some massive index scan on a spring-batch database and we noticed that these queries
COUNT_STEP_EXECUTIONS
andCOUNT_STEP_EXECUTIONS
inJdbcStepExecutionDao
can be optimized.In fact, these queries seems to use a useless sub-query, and so, will scan the
BATCH_JOB_EXECUTION
table twice.These queries can be re-written like below without any impact on the current behavior.
COUNT_STEP_EXECUTIONS :
GET_LAST_STEP_EXECUTION :
Do you see any reason to prefer the current query instead of the second one ?
Regards,
Adil
The text was updated successfully, but these errors were encountered: