[MySQL] utf-8 ์ธ์ฝ๋ฉ ํ ์ด๋ธ์์ varchar(255) ์ด๊ณผ ์ปฌ๋ผ์ ๋ํ ์ธ๋ฑ์ค ์ถ๊ฐ ๋ฐฉ๋ฒ
[ํ์]
varchar(500)์ผ๋ก ์ ์ธ๋ ์ปฌ๋ผ์ ๋ํด index๋ฅผ ์์ฑํ๋ ค๊ณ ํ๋๋ ์๋์ ๊ฐ์ ์ค๋ฅ ๋ฉ์ธ์ง๋ฅผ ํ์ธํ ์ ์์๋ค.
ย ย ย ย index column size too large. the maximum column size is 767 bytes
[์์ธ]
๊ธฐ๋ณธ์ ์ผ๋ก mysql์์๋ UTF-8 ์ธ์ฝ๋ฉ์์ varchar(255)๊ฐ ๋์ด๊ฐ ๊ฒฝ์ฐ ์ธ๋ฑ์ค๋ฅผ ์ค์ ํ ์๊ฐ ์๋ค๊ณ ๋์จ๋ค.
[ํด๊ฒฐ์ฑ ]
ํด๊ฒฐ์ฑ ์ด ๋ฌด์์ธ๊ณ ํ๋, file_format์ Barracuda๋ก ๋ณ๊ฒฝํ๋ ์์ ์ ์งํํด์ผ ํ๋ค.
Barracuda ํฌ๋งท์ ํธํ์ฑ์ ์ ์งํ๋๋ฐ ์ ๋ฆฌํ ํฌ๋งท์ด๋ผ๊ณ ๋์ด ์์ผ๋ฉฐ, ์์ถ ๋ฐ BLOB ํ์ ์ ๋ํด์๋ ํจ์จ์ ์ผ๋ก ๋์ํ๋ค๊ณ ํ๋ค.
๋ฐ๋ผ์ ์๋์ ๊ฐ์ด ๋ณ๊ฒฝํด์ผ ํ๋ค.
innodb_file_format=Barracuda
innodb_file_per_table=true
[๊ณผ์ ]
๊ทธ๋ฐ๋ฐ, RDS์ ๊ฒฝ์ฐ ๋ฐ๋ก ๋ณ๊ฒฝํ ์๊ฐ ์๊ณ ์๋ฒ ์ฌ์์์ ํด์ผ ํ๋ค. ๊ทธ๋์ ์ ์์ ์ธ ์๋น์ค๋ฅผ ํ ์ ์๊ธฐ ๋๋ฌธ์ ๋ฐฉ๋ฒ์ ์ฐพ์๋ณด์๋๋,
AWS RDS CLI (Command Line Interface)๋ฅผ ์ด์ฉํ๋ฉด ์ฆ์ ์ ์ฉ์ด ๊ฐ๋ฅํ๋ค.
RDS CLI ์ค์ ์๋ ๋ฌธ์๋ฅผ ์ฐธ๊ณ ํ๋ค.
http://docs.aws.amazon.com/AmazonRDS/latest/CommandLineReference/StartCLI.html
์ธํ ์ ํ๊ณ DB parameter group ์ ์ ๊ทผํด๋ณธ๋ค.
[์ค์ ์์ ]
# parameter group ์ด๋ฆ๊ณผ credential file ์ด๋ฆ ๋ฐ๊ฟ์ ์งํํจ.
bin/rds-describe-db-parameter-groups pg --region ap-northeast-1 --aws-credential-file credential-file-path.template
DBPARAMETERGROUP ย pg ย mysql5.6 ย pg
๋ฐ๊พธ๊ณ ์ถ์๊ฑด parameter group์ innodb_file_format ์์ฑ๊ฐ์ด๋ฏ๋ก rds-modify-db-parameter-group์ ๋ณ๊ฒฝํ์ฌ ์งํํ๋ค.
# ์ค์ ์ํํ ๋ parameter group ์ด๋ฆ๊ณผ credential file ์ด๋ฆ ๋ฐ๊ฟ์ ์งํํจ.
bin/rds-modify-db-parameter-group pgย -p "name=innodb_file_format, value=Barracuda, method=immediate" --region ap-northeast-1 --aws-credential-file credential-file-path ย ย ย
# ๋ณ๊ฒฝ ๋ ๊ฒ ํ์ธํ
innodb_file_format=barracuda
innodb_file_per_table=true
ย ์ ๋ง๋ก ํ์ํ ์์ ์ ๋์ ํ ์ด๋ธ์ ROW_FORMAT์ ๋ฐ๊พธ๋ ์์ ์ด๋ค.
์๋์ ๊ฐ์ด ์ฟผ๋ฆฌ๋ฅผ ์ํํ๋ค.
# altering table ์งํ
ALTET TABLE table_name ROW_FORMAT=DYNAMIC ;ย
# infromation_schema ์์ ๊ฒฐ๊ณผ๊ฐ์ ํ์ธํ๋ค.
mysql> select table_name, engine, row_format, create_options from tables where table_name = 'survey';
+------------+--------+------------+--------------------+ |
table_name | engine | row_format | create_options
| +------------+--------+------------+--------------------+ |
survey | InnoDB | Dynamic | row_format=DYNAMIC |
ย ์ ์์ ์ผ๋ก ๋ ๊ฒ์ ํ์ธํ์ผ๋ฉด ์ค์ ์ถ๊ฐํ๊ณ ์ ํ๋ ์ธ๋ฑ์ค๋ฅผ ์์ฑํ๋ค.
# index ์ถ๊ฐ
START TRANSACTION;
ALTER TABLE survey ADD INDEX `idx_title` (`title`);
ALTER TABLE survey ADD INDEX `idx_question_count` (`question_count`);
ALTER TABLE survey ADD INDEX `idx_created_manager_nickanme` (`created_manager_nickname`);
ALTER TABLE survey ADD INDEX `idx_updated_manager_nickanme` (`updated_manager_nickname`);
COMMIT;
ย [๋กค๋ฐฑ ์๋๋ฆฌ์ค]
# ์๋์ ์ค์ ๊ฐ์ผ๋ก ๋ณ๊ฒฝ
bin/rds-modify-db-parameter-group pgย -p "name=innodb_file_format, value=Antelope
, method=immediate" --region ap-northeast-1 --aws-credential-file credential-file-path ย ย
ย #์๋์ ์ค์ ๊ฐ์ผ๋ก ๋ณ๊ฒฝ
ALTET TABLE table_name ROW_FORMAT=COMPACT;
ย [์ฐธ๊ณ ์๋ฃ]
http://dev.mysql.com/doc/innodb/1.1/en/innodb-other-changes-file-formats.html
https://blogs.oracle.com/mysqlinnodb/entry/innodb_compression_improvements_in_mysql
http://dev.mysql.com/doc/innodb/1.1/en/glossary.html#glos_barracuda
http://blog.jidolstar.com/865











