0

I am using Spring Batch MongoDB API. In order to free up some space in my MongoDB, I decided to clean up the job execution metadata by deleting any data older than two months from the following collections : - JobInstance - JobExecution - ExecutionContext - StepExecution

Is there any way to do this with spring batch, or I should just create a Dao and bulk delete each collection's old data.

ZenRadLad
  • 82
  • 1
  • 12

2 Answers2

1

Is there any way to do this with spring batch, or I should just create a Dao and bulk delete each collection's old data.

Spring Batch does not provide that OOTB, so you need to do it yourself (using a Spring Batch job for instance ;-)). I'm not familiar with the MongoDB job repository implementation you shared (collection definition, relations between them, etc), but here are some useful links that might help you:

Mahmoud Ben Hassine
  • 28,519
  • 3
  • 32
  • 50
1

You may setup TTL indexes for mentioned collections (with mongo Shell).

If you need to free disk space (works only WiredTiger), you may use compact command (compact requires dbAdmin privileges) [Dropping collection also reclames space from MongoDB].

With collStats command you can check how many space you can reclame from MongoDB

Valijon
  • 12,667
  • 4
  • 34
  • 67
  • I didn't know that TTL Indexes exists in mongodb, thanks. But, it doesn't suit my use case as I already have data in production. I am going to use a spring batch job to clean the metadata. – ZenRadLad Feb 01 '20 at 17:06