Spring Batch persists every job run in six metadata tables. BATCH_JOB_INSTANCE is the top of the hierarchy - one row per logical job identified by name plus key. Each run adds a BATCH_JOB_EXECUTION row with status, exit code, and timestamps; parameters land in BATCH_JOB_EXECUTION_PARAMS; each step adds a BATCH_STEP_EXECUTION row with read/write/skip counters; and restart state is serialized into the two _CONTEXT tables. The design detail that surprises people: the _ID primary keys are not database-generated - they come from separate sequences, because the key must be set on the Java object right after insert.
Spring Batch 6.0.6 schema-postgresql.sql. The official DDL uses unquoted uppercase names, which PostgreSQL stores in lowercase; this page and its copied DDL use those lowercase names.
The three BATCH_*_SEQ sequences are omitted; the application assigns the IDs before inserting. schema-postgresql.sql v6.0.6.
Scroll horizontally to see the full diagram. Click it to open at full size.
One batch job execution can have many batch job execution params (batch_job_execution_params.job_execution_id -> batch_job_execution.job_execution_id, required).
Each batch step execution context has one batch step execution (batch_step_execution_context.step_execution_id -> batch_step_execution.step_execution_id, required).
Each batch job execution context has one batch job execution (batch_job_execution_context.job_execution_id -> batch_job_execution.job_execution_id, required).
One batch job execution can have many batch job execution params (batch_job_execution_params.job_execution_id -> batch_job_execution.job_execution_id, required).
Each batch step execution context has one batch step execution (batch_step_execution_context.step_execution_id -> batch_step_execution.step_execution_id, required).
Each batch job execution context has one batch job execution (batch_job_execution_context.job_execution_id -> batch_job_execution.job_execution_id, required).
Common queries
These PostgreSQL queries run against the schema shown on this page.
Recent job executions
Show the latest job runs with their instance name.
select ji.job_name, je.job_execution_id, je.status, je.create_time
from batch_job_execution je
join batch_job_instance ji on ji.job_instance_id = je.job_instance_id
order by je.create_time desc;
Failed steps
List step executions that ended in FAILED status.
select je.job_execution_id, se.step_name, se.status, se.exit_code
from batch_step_execution se
join batch_job_execution je on je.job_execution_id = se.job_execution_id
where se.status = 'FAILED'
order by se.step_execution_id;
Read and write totals
Sum step counters grouped by step name.
select step_name,
sum(read_count) as read_count,
sum(write_count) as write_count
from batch_step_execution
group by step_name
order by step_name;
Job parameters
Show the parameters supplied to each execution.
select jp.job_execution_id, jp.parameter_name, jp.parameter_value
from batch_job_execution_params jp
order by jp.job_execution_id, jp.parameter_name;
Frequently asked questions
Six tables: BATCH_JOB_INSTANCE, BATCH_JOB_EXECUTION, BATCH_JOB_EXECUTION_PARAMS, BATCH_STEP_EXECUTION, BATCH_STEP_EXECUTION_CONTEXT, and BATCH_JOB_EXECUTION_CONTEXT. Together they record every job instance, execution, step, parameter, and restart checkpoint.
A job instance is the logical job (name + identifying key) - one row no matter how many times it runs. Each run creates a new job execution row pointing back at the instance, so restarts and retries share one instance with many executions.
Because the generated key must be assigned to the Java domain object immediately after insert. Sequences let Spring Batch fetch the ID first, set it on the object, then insert - a pattern that works uniformly across all supported databases.