PostgeSQL
[PostgreSQL] CTID 단편화하기(?)
성엽이
2014. 5. 13. 16:06
postgres=# select *, ctid from t;
index | ctid
------+-------
1 | (0,1)
2 | (0,2)
3 | (0,3)
4 | (0,4)
(4 rows)
1번 레코드를 5번 으로 업데이트하면
postgres=# update t set index=10 where index=1;
UPDATE 1
postgres=# select *, ctid from t;
index | ctid
------+-------
2 | (0,2)
3 | (0,3)
4 | (0,4)
5 | (0,5)
(4 rows)
이것을 다시 순서대로 해주려면
VACUUM FULL ! 하면 됩니다.
postgres=# VACUUM FULL t;
VACUUM
postgres=# select *, ctid from t;
index | ctid
------+-------
2 | (0,1)
3 | (0,2)
4 | (0,3)
5 | (0,4)
(4 rows)