I don't have any mock db hence question:
Is there are way to create a 1gb of mock data programmatically/through query something like:
while table size < 1gb keep populating table ABC with 1
I would like to just run this query on each db server instead of moving around and uploading mock sql dump each time.
Thanks.
create table abc (
abc_id serial primary key,
data int not null
);
create or replace function abc_fill(size int, chunk_size int default 100000)
returns void
language plpgsql
as $$
begin
while pg_total_relation_size('abc')<size loop
insert into abc (data)
select 1 from generate_series(1,chunk_size);
end loop;
end;
$$;
select abc_fill(1024*1024*1024);
select pg_size_pretty(pg_total_relation_size('abc'));
1025 MB
select count(*) from abc;
18300000