I am analyzing the size of some tables in Oracle, and I noticed that the primary key occupies almost the same size of its related table.
To be clear, my statistics are the following (approx.):
NAME | TYPE | SIZE
----------------------------
MYTABLE | TABLE | 21 GiB
PK_MYTABLE | INDEX | 20 GiB
MYTABLE has four columns, and three of them composes the primary key. So the sizes should be correct.
- But why do Oracle stores this so inefficiently? (a separated structure for the primary key)
- Do Oracle has something similar to MS SQL's clustered index, that makes the index part of the related table?
- Is there something I can do to avoid this?
Best Answer
It is inefficient for this use case.
It is called IOT (Index-organized Table) in Oracle.
Overview of Index-Organized Tables
For example:
With this, you will have only one segment caled
PK_MYTABLE
.See above.