InnoDBã®ãããï¼ä»®ï¼ãèªãã§æãã¯Appendixï¼ååï¼
注æ
ãã®è¨äºã®å 容ã¯å®å ¨ã«ä¸é¨ã®ã¨ã³ã¸ãã¢ããããããããªããããã§é«åº¦ãªè©±é¡ãåãä¸ãã¾ããã¨ã³ã¸ãã¢ä»¥å¤ã®äººãèªãã§ãæå³ãåãããªãã ããããç解ã«å¿ è¦ãªå´åã«å¯¾ããå¾ããããã®ã¯å¤ãã¯ããã¾ããã
Â
ã¯ããã«
ç§ã®å°æ¬ããã¨ã³ã¸ãã¢ã§ããç¬å³¶ãããåä½ã¹ã©ã¤ããå ¬éããã¾ããã
Â
åè¿°ã®è³æã¯DBAã§ããç¬å³¶ããã®ç®ç·ã§æ¸ããã¦ãããã¾ãå 容ã¨ãã¦ãæ¯è¼çMySQLã¸ã®ç解ããã人åãã§ãããããã¢ããªã±ã¼ã·ã§ã³ã¨ã³ã¸ãã¢ã§ããç§ã®ç®ç·ããç¹ã«éè¦ãªç¹ã«ã¤ãã¦è§£èª¬ã»èå¯ãè£è¶³ãããã¾ãã
ããããã®ã¯ãªã
ãã»ã©æ¿ããæ´æ°ãããã»ã©å¤§ãããã¼ã¿éãæ±ããªãéããMySQLã¯ããã©ã«ãã®è¨å®ã§ã常èã®ç¯å²å ã®ã³ã¹ãã§åä½ãã¾ããç¹ã«AWSãªã©ã®ãããªãã¯ã¯ã©ã¦ãã§ã¯ããªãæè»ã«ãªã½ã¼ã¹ã確ä¿ãããã¨ãã§ãã¾ããMySQLã¯æããªãã
Â
ã§ã¯ãã®è³æã¯ä½ã®å½¹ã«ç«ã¤ã®ãã¨ãã話ã§ãã
- ãã»ã©æ¿ããæ´æ°ããã»ã©å¤§ãããã¼ã¿éãæ±ã
- ã¨ã¦ãéå¹ççãªä½¿ãæ¹ããã¦ãã¾ã£ã
- äºç®ã«å¤§ããªå¶éããã
ãã®ãããªã¨ãã¸ã±ã¼ã¹ã«ç´é¢ããå ´åã«å©ãã«ãªãã¾ãããã®ãããªã¨ãã¸ã±ã¼ã¹ã«ã©ã®ãããªã·ããªãªãããå¾ããã¨ããã¨
- è¨ç»ããããµã¼ãã¹ã®æé·ãç°å¸¸ã«éã
- ã¢ããªã±ã¼ã·ã§ã³ã§ä½¿ç¨ãã¦ããORMã®ã¯ã¨ãªã®å¹çãæªã
- æåã«ãµã¼ãã¹è¦æ¨¡ã大ããè¦ç©ãã£ã¦ãããå®éã¯å³ãããã³ã¹ãã«ãããæ±ãããã
ä¾ãã°ãããªæãã§ãã
ã²ã¼ã ã® DB ã¨ã²ã¼ã 以å¤ã® DB ã¯ã èãæ¹ãå¤ãã¦è¯ã
ããã§ç解ãã¹ããã¨ã¯ãç®çã«åããã¦åççé¸æããããã¨ã§ãããã³ã¹ããæããããã¨ãããã¨ã§ããåççé¸æãè¡ãããã«ã¯ç®æ¨ã®è¨å®ã¨ã¨ãã«MySQLã¸ã®ç解ãå¿ è¦ã§ããã¤ã¾ãã¨ããMySQLã®ãã¨ãããããã£ã¦ããã¨ã³ã¹ããä¸ããããï¼
sharding ã®ã¡ãªãã
ããã§ã¯æé»çã«innodb_file_per_table
ãæå¹ã§ããã¨ããåæã§è©±ãããã¦ãã¾ãããã®è¨å®å¤ã¯MySQL5.6ãããã§ããã©ã«ãæå¹ã«ãªã£ãã®ã§ãæè¿ã®MySQLã使ã£ã¦ããå ´åãåæã«æå¹ã«ãªã£ã¦ããã§ãããããã®è¨å®ã«ã¤ãã¦è©³ããæ
å ±ãç¥ãããå ´åã
MySQL :: MySQL 5.6 ãªãã¡ã¬ã³ã¹ããã¥ã¢ã« :: 14.5.2 InnoDB File-Per-Table ã¢ã¼ã
ãåèã«ãã¦ãã ããã
Â
ãã¼ãã«ã®ãã¼ã¿ãµã¤ãºã¯å¤§ãããªããããã¨éç¨ä¸ããã¤ãã®ãã¡ãªãããããã¾ãï¼å ·ä½çãªä¾ã¯è³æãåç §ï¼ãããã¯ãã¼ãã«ãåå²ããï¼shardingï¼ãã¨ã§ããç¨åº¦åé¿ã§ãã¾ãããã ããããã¯ã¯ã¨ãªã®èªç±åº¦ãä¸ãããã¨ã«ãã¤ãªããã®ã§ãã·ã£ã¼ãã£ã³ã°ã®ãã¼ã工夫ãããã¨ã§ãã®å½±é¿ãæä½éã«ã¨ã©ããã¨ããã§ãããã
Â
è³æã«ãªããã¡ãªããã¨ãã¦ã¯ããã¼ãã«ã®æ°ãå¤ããªãã®ã§çµæçã«ãã¡ã¤ã«ã·ã¹ãã ä¸ã«é ç½®ãããibdãã¡ã¤ã«ã®æ°ãå¢ãã¾ããã©ã®ç¨åº¦shardingãè¡ããã«ãããã¾ãããinnodb_open_filesã®è¨å®å¤ãå®æ ã«åãããã«ãã¾ãããã
Â
ã©ãã§ããã話ã§ãããç§ã¯alter tableã«æ大ã§3æ¥ããã£ããã¨ãããã¾ãã
MySQL ã®æ©è½ãæ´»ããã¦ã Transaction ã¯ã»ã©ã»ã©ã«èãã
ããã¯ãã£ã¨é«åº¦ãªè©±ã«ãªãã¾ããé å¼µã£ã¦ã¤ãã¦ããããèªã¿é£ã°ãããã¾ãããã
Â
å¤ãã®SQLãã©ã¤ãã¼ã§ã¯æ´æ°ç³»ã¯ã¨ãªã®è¿ãå¤ãããæ´æ°ãããã¬ã³ã¼ãæ°ãå¾ããã¨ãã§ãã¾ããæ¹ãã¦select count(*)ï½whereã§åå¾ãããããä½ã³ã¹ããã¤ç¢ºå®ã«æ°ãæ°ãããã¨ãã§ããã®ã§ãæ´»ç¨ãã¾ãããã
Â
ååã ãinsertãã¦ä»¥éupdateã®å ´åï½ã¨ããã®ã¯ãinsertãããã¨ãã¦å¤±æããã®å¾updateã¨ããåä½ãéå¹ççã«ãªãããã§ããinsertããã¹ã確çãããupdateããã¹ã確çãå§åçã«é«ãå ´åããããªãupdateããã®ã»ããå¹ççã§ãã
MySQL 以å¤ã® ãã¼ã¿ã¹ãã¢ããã£ãã·ã¥ã¨ã ãã¾ãçµã¿åããã
ããã¯æåã®æ®µè½ã®çºå±å½¢ã§ããMySQLï¼InnoDBï¼ã¯é常ã«å ç¢ãªãã¼ã¿ã¹ãã¢ã§ãããã¢ããªã±ã¼ã·ã§ã³ã®ãã¹ã¦ã®å ´é¢ã§åä¸ã®å ç¢æ§ãè¦æ±ãããããã§ã¯ããã¾ãããMySQLã®ç¹æ§ãç解ããä¸å¾æãªãã®ï¼è¶ é«é »åº¦æ´æ°ã»è¶ ãªã¢ã«ã¿ã¤ã ãªã©ï¼ã¯ããã«ãã£ããã¼ã¿ã¹ãã¢ãçµã¿åããããã¨ã§ã³ã¹ããä¸ãããã¾ãã
Â
è³æã«æãããã¦ããªããã®ã§ããã°ãã¢ããªã±ã¼ã·ã§ã³ãã®ãã®ã®ã¡ã¢ãªã®ä¸ã«ãã£ãã·ã¥ã¨ãã¦ä¿æããã®ãããæ¹æ³ã§ããã¾ããããã¤ãã®æ¹æ³ãçµã¿åããã¦ãã£ãã·ã¥ãå¤æ®µã«ãããã¨ãã¾ã¾ããã¾ãã
ã¢ããªã±ã¼ã·ã§ã³ã¨ã³ã¸ãã¢ã¨ãã¦ã¯ã©ã®ãã¼ã¿ãã©ãã«ãã©ã®ç¨åº¦ã®å¯¿å½ã§ãã£ãã·ã¥ããã¦ããããææ¡ãããã¨ãéè¦ã§ãã
Â
ã¾ããã¡ã¢ãªå ãã£ãã·ã¥ï¼memcachedããã¼ã«ã«ã¡ã¢ãªï¼ã¯ãªã¹ã¿ã¼ãã§ãã¼ã¿ãå¹ãé£ã¶å¯è½æ§ãããããã®éã«DBã®è² è·ãæ¥æ¿ã«ä¸ããå ´åãããã¾ããã¢ããªã±ã¼ã·ã§ã³ã®ã¤ãã次第ã§ã¯é£éçãªé害ãçºçãããå ´åãããã®ã§ããããèæ ®ããããã§DBã®æ§è½ãè¦ç©ããã¾ãããã
Â
é·ããªã£ãã®ã§æ®ãã¯å¾åã«åãã¾ãã
å¹´åã100ä¸åä¸ããäºè±¡ã«ã¤ãã¦
æã ã¯ä»¥åããç¹å®ã®æ¥çãç¹å®ã®ä¼æ¥ã«ãããè¤æ°ã®äºè±¡ã観測ãã¦ããããã®äºè±¡ã«ã¤ãã¦ãèèç«ãã¨å¼ãã§ããã¾ãã
èèç«ã¨ååãä»ããããçµç·¯ã«ã¤ãã¦ãç§ã®ç¥ãéã以ä¸ã®ããã«ä¼ãèãã¦ããã¾ãã
ããã¨ããã«æï¼ä»®åï¼ã¨ãã社å¡ãããã
æã¯æ¯å¹´ã®è©ä¾¡ã®ãã³ã«å¹´åãå¤ãããªããã¨ãåãã¦ããã
ãããªæã§ããããããå¹´ã®è©ä¾¡é¢è«ã§ãåçªã«å¹´åã100ä¸åä¸ãããã¨ãåããããã
æã¯å¤§ãã«åããã
ããã¾ã§ã¯å¹´åãå¤ãããªããã¨ãåãã¦ããããä»ãæãã°å¤ãããªããã¨ããä½ã§ããªããããªãã¨ã幸ãã ã£ãã®ã ãæã¯ããäºåº¦ã¨æ»ããªãæ¥ã ãæããããæ¯ãã¤ããã¨ããã§ããªãã£ãã
ãã®è©±ãèãã人ã ã¯ãåæ²ããã¼ããã«ãªãããã¦ãå¹´åãæ¥æ¿ã«ä½ä¸ãããã¨ããèèç«ãã¨å¼ã¶ããã«ãªã£ãã
以ä¸ããããããé¡ããããã¾ãã
ç¼ããã°
ããããã§ãã