Created
March 13, 2024 11:50
-
-
Save mvdbeek/fc352f0f21a5eca14b8f7416f34e95e5 to your computer and use it in GitHub Desktop.
delete first 100 user and history-item-less histories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BEGIN; | |
-- Clean up pgcleanup table | |
DELETE FROM cleanup_event_history_association WHERE cleanup_event_history_association.history_id IN (SELECT id FROM history WHERE history.user_id is null AND history.hid_counter = 1 ORDER BY history.update_time LIMIT 100); | |
-- Clean up audit table | |
DELETE FROM history_audit WHERE history_audit.history_id IN (select id from history where history.user_id is null and history.hid_counter = 1 ORDER BY history.update_time LIMIT 100); | |
-- Cleanup galaxy_session_to_history | |
DELETE FROM galaxy_session_to_history WHERE galaxy_session_to_history.session_id IN (SELECT galaxy_session.id FROM galaxy_session WHERE galaxy_session.current_history_id IN (SELECT history.id FROM history WHERE history.user_id is null AND history.hid_counter = 1 ORDER BY history.update_time LIMIT 100)); | |
-- Clean up galaxy_session | |
DELETE FROM galaxy_session WHERE galaxy_session.current_history_id IN (select id from history where history.user_id is null AND history.hid_counter = 1 ORDER BY history.update_time LIMIT 100); | |
-- Now clean up actual history table (start with 100 histories) | |
DELETE FROM history where id in (select id from history where history.user_id is null and history.hid_counter = 1 ORDER BY history.update_time LIMIT 100); | |
ROLLBACK; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment