Overview
The Analytics Cleanup Job is a scheduled maintenance task responsible for removing outdated analytics data based on a configured retention policy.
Its primary purpose is to:
Enforce data retention rules
Reduce long-term database growth
Maintain analytics table performance
Prevent excessive storage consumption
The job permanently deletes analytics records that exceed the configured retention period.
What the Job Does
During execution, the job:
Identifies analytics records older than the configured retention threshold
Deletes eligible records in controlled batches
Limits total work per run based on configuration
Stores execution metadata for diagnostics and monitoring
The job does not modify active or recent analytics data.
Only records exceeding the retention period are removed.
Configuration
The Analytics Cleanup Job can be configured via application properties.
1. Enabled / Disabled
Property:
newired.analytics-cleanup.enabled
Type: boolean
Default: true
Purpose:
Controls whether the cleanup job is active.
true – Job runs according to the configured schedule
false – Job is completely disabled
2. Schedule
Property:
newired.analytics-cleanup.schedule
Runs daily at 03:00.
Type: Cron Expression
Default: 0 0 3 * * *
Purpose:
Defines how often the cleanup job runs.
It is recommended to schedule execution outside peak business hours to minimize database load.
3. Retention Period
Property
newired.analytics-cleanup.retention-days
Default: 1095 (days)
Purpose:
Defines how old analytics records must be before they are eligible for permanent deletion.
Only data older than this threshold will be removed.
4. Batch Size
Property
newired.analytics-cleanup.actions-per-batch
Default: 10000
Purpose:
Defines how many records are deleted in a single batch.
Controls:
Transaction size
Lock duration
Database load per operation
Lower values reduce per-transaction impact but may increase total runtime.
5. Action Types to Clean
Property
newired.analytics-cleanup.action-kinds
Default: page_view, journey, feedback, user_identify, user_activity (all action types)
Purpose:
Defines which analytics action types are eligible for cleanup.
6. Max Batches per Run
Property
newired.analytics-cleanup.max-batches-per-run
Default: 0 (no limit)
Purpose:
Limits the maximum number of batches processed during a single execution.
Prevents excessively long cleanup runs and spreads deletion across multiple schedules.
7. Database Statement Timeout
Property
newired.analytics-cleanup.statement-timeout
Default: 30min
Purpose:
Limits the maximum duration of database delete statements executed by the job.
Prevents long-running operations from blocking database resources.
Supported formats:
Milliseconds (e.g., 5000)
Seconds (e.g., 5s)
Minutes (e.g., 15min)
Hours (e.g., 1h)
Special behavior:
Setting the value to 0 disables the timeout (statement_timeout=0).
Diagnostics
A diagnostics endpoint is available for monitoring execution history:
<instance>/rest/app/diag/jobs/analytics/cleanup
The endpoint provides:
Job run history
Execution status
Number of deleted records
Duration
Error details (if any)
Access requires proper authorization (API key via request header nw-auth).
More details: https://support.newired.com/support/solutions/articles/103000391563
Operational Considerations
Since cleanup operations perform batch deletions, they may generate database load depending on dataset size and configuration.
It is recommended to:
Schedule the job during low-traffic hours
Adjust batch size if lock contention occurs
Review retention period based on storage requirements
Proper configuration ensures controlled data lifecycle management without impacting normal system performance.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article