Hangfire.Console icon indicating copy to clipboard operation
Hangfire.Console copied to clipboard

Database Size on SQL Server too big

Open luizfbicalho opened this issue 3 years ago • 0 comments

This bug is copied from https://github.com/HangfireIO/Hangfire/issues/1976

asked this question on stack overflow

https://stackoverflow.com/questions/70177605/how-can-i-clean-hangfire-sql-database-keeping-the-actual-jobs-running

My databases are too big for not that many active jobs, I looked at the database and in the Set and Hash Tables there are information that aren't linked to any active job, I mean, old suceeded jobs are deleted but their information on the Set and Hash tables aren't cleaned

What can I do to clean this records? shoudn't all of these tables have FKs to the Job table and delete cascade on it?

This Is my production size at the moment

image

I have the extensions

Hanfire.Console 1.4.2 and Hangfire.Recurringjobextenions 1.1.6

ths is the set table

image

select substring([key],0,9),count(*) from [HangFire].[Set] group by substring([key],0,9) order by 2 desc

State is also very big, I have some old jobs that run, try to do something and schedule again for some time in the future, is there a way to clean the old state from a job, I mean, I could keep just the essencial from the previous months

this is the hash table

image

select  substring([key],0,13),count(*),field  from [HangFire].Hash

group by substring([key],0,13),field
order by 1 

luizfbicalho avatar Dec 07 '21 17:12 luizfbicalho