..
Notes about postgresql
How to generate and insert test data?
For example, my table is like: create table (time timestamp, value double precision, sensor integer)
. If I want to insert some test data, I can use function generate_series
.
Following sql will insert 5000 rows:
insert into test (time, sensor, value) select now(), i, random() from generate_series(1, 5000) s(i)
How to view disk usage?
View table size
select pg_size_pretty(pg_relation_size('pressure_01'))
View database size
select pg_size_pretty(pg_database_size('pressure_01'))