Why index occupy less amount of space than the table with same structure. - Mailing list pgsql-general

From Tadipathri Raghu
Subject Why index occupy less amount of space than the table with same structure.
Date
Msg-id 645d9d71003280105j14630cddqd86ca5af8c5fe800@mail.gmail.com
Whole thread Raw
Responses Re: Why index occupy less amount of space than the table with same structure.  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
List pgsql-general
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)
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)
postgres=# select pg_size_pretty(pg_total_relation_size('size_test'));
 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
 

pgsql-general by date:

Previous
From: Tadipathri Raghu
Date:
Subject: Re: How many Mandatory Process are there in Postgres
Next
From: dipti shah
Date:
Subject: Designing Postgres Security Model