Why index occupy less amount of space than the table with same structure.

Поиск
Список
Период
Сортировка
От Tadipathri Raghu
Тема Why index occupy less amount of space than the table with same structure.
Дата
Msg-id 645d9d71003280105j14630cddqd86ca5af8c5fe800@mail.gmail.com
обсуждение исходный текст
Ответы Re: Why index occupy less amount of space than the table with same structure.
Список 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 по дате отправления: