OnStatusChanged in Optimizely CMS Scheduled JobsOptimizely CMS allows you to create scheduled jobs — a powerful feature often used to automate repetitive tasks such as product imports. Sometimes, we even use them for one-off data migrations and delete them afterward.
This post assumes you’re already familiar with the basics, but if not, you can catch up here: Optimizely Scheduled Jobs Documentation
Most developers are aware of the OnStatusChanged method. It’s handy for updating the administrative interface with progress messages while a scheduled job runs. For example, you might use it to display periodic updates like “Importing products…” or “Processing batch 2 of 5…” so that anyone monitoring the job can see what’s happening in real time.
There’s a small hiccup, though.
While investigating a performance issue for one of our clients, we noticed the database was under heavy load during certain scheduled jobs. After some digging, we realized that our frequent use of OnStatusChanged was the culprit.
Even worse, some jobs began failing with an unexpected error — one that had nothing to do with the job logic itself:
Digging through the stack trace reveals that each call to OnStatusChanged triggers a database write. Every single status update results in a new SQL transaction. If your job updates its status too frequently — say, inside a loop — you can easily overwhelm the database with hundreds or thousands of writes.
In our case, this not only degraded performance but also caused transaction errors like the one above.
Once we understood what was happening, we simply removed (or drastically reduced) our calls to OnStatusChanged. That immediately stabilized the system and reduced database load.
If your scheduled jobs make frequent calls to OnStatusChanged, we strongly suggest you review and limit them. Consider logging detailed progress elsewhere (e.g., a file, Application Insights, or custom monitoring) and only update the UI when it truly matters — such as at the start, at major milestones, or upon completion.
OnStatusChanged is a useful feature, but it’s not free. Every update hits the database. Use it sparingly to keep your jobs reliable and performant.
Hope this helps someone avoid the same headache we had!