Is it ok to make looped table for logs that has no need to live long using cycle sequence?
Only inconvenience I can see is that for log inserts you always need to add on conflic and maybe >second cycle insert will be slower because it's always be a conflict.
create table foo (
id int primary key,
data text
);
CREATE SEQUENCE id_seq MINVALUE 1 maxvalue 3 cycle;
ALTER TABLE foo ALTER COLUMN id SET DEFAULT nextval('id_seq');
insert into foo (data) values ('1') on conflict (id) do update set data='1';
insert into foo (data) values ('2') on conflict (id) do update set data='2';
insert into foo (data) values ('3') on conflict (id) do update set data='3';
insert into foo (data) values ('4') on conflict (id) do update set data='4';
select* from foo order by id;
Or maybe there is easier way to do it? Like cleaning job that will run every year by postgres itself?
Requirements:
- many logs inserts
- reasonable overall table size
- logs don't need to live long, year is enough