-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
556c839
commit 20f8357
Showing
5 changed files
with
112 additions
and
19 deletions.
There are no files selected for viewing
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
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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
create function remove_old_entries() | ||
returns trigger | ||
as $$ | ||
begin | ||
if( | ||
select | ||
COUNT(*) | ||
from | ||
table_name) > 10000 then | ||
delete from table_name | ||
where id in( | ||
select | ||
id | ||
from | ||
table_name | ||
order by | ||
id asc | ||
limit 1000); | ||
end if; | ||
return null; | ||
end; | ||
$$ | ||
language plpgsql; | ||
|
||
create trigger remove_old_entries_trigger | ||
after insert on table_name for each row | ||
execute procedure remove_old_entries(); |
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