Stop Keycloak from running event expiration queries


I am using keycloak hosted on AWS, using a RDS aurora serverless cluster. What I want on the lower environments (dev, demo, etc.) is for those aurora clusters to scale to 0 so that we don’t pay the costs while there are no users that actually use keycloak for that environment.

The issue is that once every 5 or 10 minutes, I see in the debug logs that some queries start running at some give interval. Example of query: “select distinct realm.eventsExpiration from org.keycloak.models.jpa.entities.RealmEntity realm where realm.eventsExpiration > 0”

Because keycloak runs those queries periodically, the aurora serverless cluster is prevented from scaling to 0, so we end up paying for 24h hours per day of uptime.

Is there any way to increase the interval for which those queries run? Or can we disable it at all?

We are using this docker image: Quay. I also tried disabling health check, metrics, setting all Sessions settings in all realms to 30 days and all token settings for all realms to 30 days.