Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean the syncv3_snapshots table periodically #422

Merged
merged 2 commits into from
Apr 24, 2024
Merged

Clean the syncv3_snapshots table periodically #422

merged 2 commits into from
Apr 24, 2024

Conversation

kegsay
Copy link
Member

@kegsay kegsay commented Apr 22, 2024

Also cleans the transaction table periodically.

Fixes #372

On testing, this cuts db size to about 1/3 of its original size.

kegsay added 2 commits April 22, 2024 08:55
Also cleans the transaction table periodically.

Fixes #372

On testing, this cuts db size to about 1/3 of its original size.
@kegsay kegsay requested review from S7evinK and devonh and removed request for S7evinK April 24, 2024 07:33
@kegsay kegsay merged commit abf5aef into main Apr 24, 2024
7 checks passed
@melroy89
Copy link

This query:

WITH ranked_snapshots AS (
		SELECT
		  snapshot_id,
		  room_id,
		  ROW_NUMBER() OVER (PARTITION BY room_id ORDER BY snapshot_id DESC) AS row_num
		FROM
		  syncv3_snapshots
	  )
	  DELETE FROM syncv3_snapshots USING ranked_snapshots
	  WHERE syncv3_snapshots.snapshot_id = ranked_snapshots.snapshot_id
	  AND ranked_snapshots.row_num > 51;

Is running REALLY REALLY long:

image

(discovered via: SELECT pid, now() - pg_stat_activity.query_start AS duration, query 
FROM pg_stat_activity 
WHERE (now() - pg_stat_activity.query_start) > interval '1 minute';
)

@kegsay Is this normal!?? Are you missing an index maybe on table?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

database size grows up, how to cleanup old shapshots
3 participants