Hi All,
Here is small testing done by my end and am curious to know the reason. Please find the example given below:-
postgres=# create table size_test(id int);
CREATE TABLE
postgres=# insert into size_test VALUES (generate_series(1,1000000));
INSERT 0 1000000
postgres=# select pg_size_pretty(pg_relation_size('size_test'));
pg_size_pretty
----------------
31 MB
(1 row)
CREATE TABLE
postgres=# insert into size_test VALUES (generate_series(1,1000000));
INSERT 0 1000000
postgres=# select pg_size_pretty(pg_relation_size('size_test'));
pg_size_pretty
----------------
31 MB
(1 row)
postgres=# create index isize_test on size_test(id);
CREATE INDEX
postgres=# select pg_size_pretty(pg_relation_size('isize_test'));
pg_size_pretty
----------------
17 MB
(1 row)
CREATE INDEX
postgres=# select pg_size_pretty(pg_relation_size('isize_test'));
pg_size_pretty
----------------
17 MB
(1 row)
postgres=# select pg_size_pretty(pg_total_relation_size('size_test'));
pg_size_pretty
----------------
48 MB
(1 row)
pg_size_pretty
----------------
48 MB
(1 row)
I like to know here is, I have created a table with one column and the index is on one column only, so why is the space occupied differently, almost all half of the space of the table and why not full. Could please you explain on this. And what exactly the postgres architecture treat on Index table and Ordinary table.
Thanks all in Advance
Regards
Raghavendra