본문 바로가기
카테고리 없음

Mysql - boolean사용 char(1) vs tinyint(1)

https://stackoverflow.com/questions/2023476/which-is-faster-char1-or-tinyint1-why

 

Which is faster: char(1) or tinyint(1) ? Why?

MY PLATFORM: PHP & mySQL MY SITUATION: I came across a situation where I need to store a value for user selection in one of my columns of a table. Now my options would be to: Either declare...

stackoverflow.com

오늘 mysql 데이터베이스 설계 중 boolean을 나타내는데 여태 tinyint(1)을 사용하다가 char(1)랑 비교했을때 어떤게 퍼포먼스가 더 좋을까? 생각을 해봤고 궁금함을 못 이겨 구글링 해본 결과 위의 스택오버플로우 글을 발견!

 

 

stackoverflow - Glen Solsberry의 답변

위의 답변이 보였고 그 결과는 대부분의 경우 enum을 사용하는것이 좋다고 하였다 또한 enum이기 때문에 enum('yes', 'no') 로 사용하여도 인덱스 값을 들고있는거기 때문에 결과는 같다고 한다.

 

 -> mysql에서 boolean으로 나타낼땐 컬럼 타입을 enum('no', 'yes)로 지정하기.