DBA Hub

📋Steps in this guide1/1

Find specific table/index size

postgres=# \d test Table "public.test" Column.     | Type    | Collation | Nullable | Default ------------+---------+-----------+----------+--------- sourcefile | text     |           |          | sourceline | integer  |           |          | seqno.     | integer  |           |.         | name.      | text     |           |          | setting.   | text     |           |          | applied   | boo

postgresql configurationintermediate
by PostgreSQL
14 views
1

Find specific table/index size

-- Find the table_size ( excluding the index_size) -- Find the total_index size of the table -- Find particular index size: Another method:

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
postgres=# \d test
Table "public.test"
Column.     | Type    | Collation | Nullable | Default
------------+---------+-----------+----------+---------
sourcefile | text     |           |          |
sourceline | integer  |           |          |
seqno.     | integer  |           |.         |
name.      | text     |           |          |
setting.   | text     |           |          |
applied   | boolean   |           |          |
error     | text.     |           |          |
Indexes:
"test_idx" btree (sourcefile)
"test_idx2" btree (sourceline)
postgres=#
SELECT pg_size_pretty (pg_relation_size('test'));
pg_size_pretty
----------------
30 MB
(1 row)
postgres=#
sELECT pg_size_pretty ( pg_indexes_size('test'));
pg_size_pretty
----------------
26 MB
(1 row)
postgres=#
select pg_size_pretty(pg_total_relation_size('test_idx'));
pg_size_pretty
----------------
19 MB
postgres=#
select pg_size_pretty(pg_total_relation_size('test_idx2'));
pg_size_pretty
----------------
6496 kB
postgres=#
\di+ "test_idx"
List of relations
Schema  | Name     | Type  | Owner.  | Table | Size       | Description
--------+----------+-------+---------+-------+------------+-------------
public  | test_idx | index | dbaprod | test  | 8192 bytes |
(1 row)

Comments (0)

Please to add comments

No comments yet. Be the first to comment!