
이번 글을 통해 배워 갈 내용
- GUID pk Performance in DB에 대한 생각 나눔
UUID를 쓰면 매년 10억개씩 100년 만들었을 때 중복이 나올 확률이 반반이기 때문에
UUID를 쓰면 모든 서버 모든 테이블에서 Unique 하고 데이터베이스에 record를 Merging 할 때 편합니다
IDX를 그대로 내리면 위험해서
저도 보안이 Critical 하지 않은 시스템의 경우
UUID를 Public id로 쓸 때가 있습니다
물론 철통보안의 경우 Publicid 테이블을 따로 만들어서 관리합니다
하지만 혹시 UUID를 Public Id로 내릴 필요가 없는 경우
그리고 UUID 만큼 랜덤함이 필요 없는 경우
GUID로 만드는 부분적으로 sequential 한 newsequentialid()를 쓰면 좋습니다
MSSQL에서 제공하는 기능이고요
테이블에 해당 GUID를 Insert 할 때 좋습니다.
말 그대로 Sequencial 하기 때문에 UUID 만큼 보안에 좋지는 않지만
UUID 보다 속도가 빠릅니다
칼럼 타입을 varchar 36에서 바꿔줘야 하는 단점도 있습니다.
참고로
DB가 자주 꺼진 다음 켜진다면 Sequencial 하게 생성 시 안 좋다고 합니다
그리고 백만 ROW까지는 괜찮은데 백만 ROW이상이라면 다른 방법을 찾아보는 것도 좋다고 합니다
자바에서 GUID를 생성할 때 읽어보면 좋은 흥미로운 글
https://stackoverflow.com/questions/32758726/sequential-guid-generation-in-java-with-sql-server-uniqueidentifier%EF%BB%BF
GUID를 생성하는 올바른 방법
http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt
POSTGRESSQL이라면 참조
https://dba.stackexchange.com/questions/175107/does-postgres-offer-a-feature-like-newsequentialid-in-ms-sql-server-to-make-uu
Does Postgres offer a feature like “NEWSEQUENTIALID” in MS SQL Server to make UUID as primary key more efficient
Microsoft SQL Server offers the NEWID command to generate a new GUID (the Microsoft version of UUID) value that can be used as a primary key value (in their uniqueidentifier data type). These are not
dba.stackexchange.com
참조 및 인용
Sequential GUID generation in Java with SQL Server uniqueidentifier
The problem that I'm trying to solve is: 1 - In our DB we have all the tables (also tables with millions of records) with a PK id column declared as VARCHAR(36). There is also a clustered index on...
stackoverflow.com
NEWSEQUENTIALID (Transact-SQL) - SQL Server
NEWSEQUENTIALID (Transact-SQL)
learn.microsoft.com
https://dba.stackexchange.com/questions/264/guid-vs-int-which-is-better-as-a-primary-key
Guid vs INT - Which is better as a primary key?
I've being reading around reasons to use or not Guid and int. int is smaller, faster, easy to remember, keeps a chronological sequence. And as for Guid, the only advantage I found is that it is un...
dba.stackexchange.com
What are the best practices for using a GUID as a primary key, specifically regarding performance?
I have an application that uses GUID as the Primary Key in almost all tables and I have read that there are issues about performance when using GUID as Primary Key. Honestly, I haven't seen any pro...
stackoverflow.com
http://web.archive.org/web/20110526141832/http://www.fotia.co.uk/fotia/DY.19.NewSequentialId.aspx
All Fired Up...: The NEWSEQUENTIALID Function
The NEWSEQUENTIALID Function posted by Stefan Delmarco The NEWSEQUENTIALID system function is an addition to SQL Server 2005. It seeks to bring together, what used to be, conflicting requirements in SQL Server 2000; namely identity-level insert performance
web.archive.org
블로그 추천 포스트
https://codemasterkimc.tistory.com/50
300년차 개발자의 좋은 코드 5계명 (Clean Code)
이번 글을 통해 배워갈 내용 좋은 코드(Clean Code)를 작성하기 위해 개발자로서 생각해볼 5가지 요소를 알아보겠습니다. 개요 좋은 코드란 무엇일까요? 저는 자원이 한정적인 컴퓨터 세상에서 좋
codemasterkimc.tistory.com
오늘도 즐거운 코딩 하시길 바랍니다 ~ :)
'DB' 카테고리의 다른 글
SQL The user specified as a definer ('root'@'%') does not exist 해결하는 한가지 방법 (0) | 2023.11.01 |
---|---|
PostgreSQL에서 값이 존재하는지 확인하는 한가지 방법 / Exists (0) | 2023.01.07 |
생각) SQL 서버에서 공백문자열을 쓰는게 NULL을 쓰는것 보다 좋은 한가지 이유 (0) | 2022.10.31 |
PostgreSql pgAdmin 서버로 연결해보기 (0) | 2022.09.21 |
PostgreSql 비밀번호 분실시 초기화 하는 방법(윈도우) (0) | 2022.09.21 |

이번 글을 통해 배워 갈 내용
- GUID pk Performance in DB에 대한 생각 나눔
UUID를 쓰면 매년 10억개씩 100년 만들었을 때 중복이 나올 확률이 반반이기 때문에
UUID를 쓰면 모든 서버 모든 테이블에서 Unique 하고 데이터베이스에 record를 Merging 할 때 편합니다
IDX를 그대로 내리면 위험해서
저도 보안이 Critical 하지 않은 시스템의 경우
UUID를 Public id로 쓸 때가 있습니다
물론 철통보안의 경우 Publicid 테이블을 따로 만들어서 관리합니다
하지만 혹시 UUID를 Public Id로 내릴 필요가 없는 경우
그리고 UUID 만큼 랜덤함이 필요 없는 경우
GUID로 만드는 부분적으로 sequential 한 newsequentialid()를 쓰면 좋습니다
MSSQL에서 제공하는 기능이고요
테이블에 해당 GUID를 Insert 할 때 좋습니다.
말 그대로 Sequencial 하기 때문에 UUID 만큼 보안에 좋지는 않지만
UUID 보다 속도가 빠릅니다
칼럼 타입을 varchar 36에서 바꿔줘야 하는 단점도 있습니다.
참고로
DB가 자주 꺼진 다음 켜진다면 Sequencial 하게 생성 시 안 좋다고 합니다
그리고 백만 ROW까지는 괜찮은데 백만 ROW이상이라면 다른 방법을 찾아보는 것도 좋다고 합니다
자바에서 GUID를 생성할 때 읽어보면 좋은 흥미로운 글
https://stackoverflow.com/questions/32758726/sequential-guid-generation-in-java-with-sql-server-uniqueidentifier%EF%BB%BF
GUID를 생성하는 올바른 방법
http://www.opengroup.org/dce/info/draft-leach-uuids-guids-01.txt
POSTGRESSQL이라면 참조
https://dba.stackexchange.com/questions/175107/does-postgres-offer-a-feature-like-newsequentialid-in-ms-sql-server-to-make-uu
Does Postgres offer a feature like “NEWSEQUENTIALID” in MS SQL Server to make UUID as primary key more efficient
Microsoft SQL Server offers the NEWID command to generate a new GUID (the Microsoft version of UUID) value that can be used as a primary key value (in their uniqueidentifier data type). These are not
dba.stackexchange.com
참조 및 인용
Sequential GUID generation in Java with SQL Server uniqueidentifier
The problem that I'm trying to solve is: 1 - In our DB we have all the tables (also tables with millions of records) with a PK id column declared as VARCHAR(36). There is also a clustered index on...
stackoverflow.com
NEWSEQUENTIALID (Transact-SQL) - SQL Server
NEWSEQUENTIALID (Transact-SQL)
learn.microsoft.com
https://dba.stackexchange.com/questions/264/guid-vs-int-which-is-better-as-a-primary-key
Guid vs INT - Which is better as a primary key?
I've being reading around reasons to use or not Guid and int. int is smaller, faster, easy to remember, keeps a chronological sequence. And as for Guid, the only advantage I found is that it is un...
dba.stackexchange.com
What are the best practices for using a GUID as a primary key, specifically regarding performance?
I have an application that uses GUID as the Primary Key in almost all tables and I have read that there are issues about performance when using GUID as Primary Key. Honestly, I haven't seen any pro...
stackoverflow.com
http://web.archive.org/web/20110526141832/http://www.fotia.co.uk/fotia/DY.19.NewSequentialId.aspx
All Fired Up...: The NEWSEQUENTIALID Function
The NEWSEQUENTIALID Function posted by Stefan Delmarco The NEWSEQUENTIALID system function is an addition to SQL Server 2005. It seeks to bring together, what used to be, conflicting requirements in SQL Server 2000; namely identity-level insert performance
web.archive.org
블로그 추천 포스트
https://codemasterkimc.tistory.com/50
300년차 개발자의 좋은 코드 5계명 (Clean Code)
이번 글을 통해 배워갈 내용 좋은 코드(Clean Code)를 작성하기 위해 개발자로서 생각해볼 5가지 요소를 알아보겠습니다. 개요 좋은 코드란 무엇일까요? 저는 자원이 한정적인 컴퓨터 세상에서 좋
codemasterkimc.tistory.com
오늘도 즐거운 코딩 하시길 바랍니다 ~ :)
'DB' 카테고리의 다른 글
SQL The user specified as a definer ('root'@'%') does not exist 해결하는 한가지 방법 (0) | 2023.11.01 |
---|---|
PostgreSQL에서 값이 존재하는지 확인하는 한가지 방법 / Exists (0) | 2023.01.07 |
생각) SQL 서버에서 공백문자열을 쓰는게 NULL을 쓰는것 보다 좋은 한가지 이유 (0) | 2022.10.31 |
PostgreSql pgAdmin 서버로 연결해보기 (0) | 2022.09.21 |
PostgreSql 비밀번호 분실시 초기화 하는 방법(윈도우) (0) | 2022.09.21 |