지금 설계하고 있는 DB구조의 Primary key와 foreign key를 serial로 할지, uuid로 할지 고민중에 둘의 join 성능을 비교한 글이 있어서 기록해둔다.
참고 : https://www.cybertec-postgresql.com/en/int4-vs-int8-vs-uuid-vs-numeric-performance-on-bigger-joins/
Datatype | JOIN mean time 5m rows (s) | % diff. to smallest | Index Size (MB) | % diff. to smallest |
---|---|---|---|---|
int4 | 2.72 | – | 107 | – |
int8 | 2.95 | +8 % | 107 | – |
numeric | 3.65 | +34 % | 107 | – |
uuid | 3.07 | +13 % | 150 | +40 % |
uuid 를 썼을때 int4 (serial) 과 거의 차이가 안난다.
성능보다는 사용성에 주의해서 어떤 타입을 쓸지 결정하면 될듯