ãªã¬ã°ã»ãã¡ã¬ãïŒ zabivator ïŒ
ãã¹ã¿ãŒãããŠããã¹ã¿ãŒãçªç¶èœã¡ãŸããããã·ã¹ãã ã¯åäœãç¶ããŸãã 顧客ã¯2çªç®ã®ããŒã¹ã«ç§»è¡ããŸãã ããŒã¿ããŒã¹ã®ããã¯ã¢ããã³ããŒãäœæããå¿ èŠããããŸãã ã¡ã€ã³ããŒã¿ããŒã¹ã§ããã¯ã¢ãããäœæãããšãäœããã®ããã©ãŒãã³ã¹ã®åé¡ãå¿çæéã®å¢å ãçºçããå¯èœæ§ããããŸãã ããã¯æªãã§ãã ãããã£ãŠãéåæè€è£œã®ããªãäžè¬çãªäŸã¯ãã¹ã¬ãŒãããã®ããã¯ã¢ããã®åé€ã§ãã ãã1ã€ã®äŸã¯ããã¹ã¿ãŒããŒã¿ããŒã¹ããã¹ã¬ãŒããžãã¡ã€ã³ããŒã¿ããŒã¹ãã2çªç®ãžã®éãã¯ãšãªã®ç§»è¡ã§ãã ããšãã°ãã¬ããŒãã®äœæã
ã¢ããªã±ãŒã·ã§ã³ãããŒã¿ããŒã¹ãããã¹ãŠã®æŽæ°ããã§ããã°ãªã¢ã«ã¿ã€ã ã§åä¿¡ã§ããããšãå¿ èŠãªå ŽåããããŸãã ããã¯ãlibslaveãšåŒã°ãããªãŒãã³ãœãŒã¹ã©ã€ãã©ãªã«ãã£ãŠè¡ãããŸãã
ãã®èšäºã¯Oleg Tsarevã®ã¬ããŒãïŒ zabivator ïŒã®è»¢åã§ãããOlegããã®äž»é¡ã«é¢ããå¥ã®èšäºãå ¬éãã1幎åŸ-PostgreSQL vs MySQL ã
ã¹ã©ã€ãã®ãªã³ã¯ããã©ã£ãŠãçŽ æŽãããèšäºãèªãã§ãã ããã
ãã¹ãŠããŸãšãããšã次ã®ããã«ãªããŸãã
ãã¹ã¿ãŒãšã¹ã¬ãŒãã®æã1ã€ãããŸãããã¹ã¿ãŒãã¯ã©ãã·ã¥ããå Žåã¯ããã¯ã¢ããçšã®seiloverãããã¯ã¢ããçšã®ã¹ã¬ãŒããã¬ããŒããäœæããããã®ã¹ã¬ãŒããããã³bannerdãšåŒã°ãããã®ãžã®å€æŽãäžç¶ããè€æ°ã®ã¹ã¬ãŒãïŒããã¯ããŒã¢ã³ã®ååã§ãããlibslaveãä»ããŠæ©èœããŸãïŒ ã ãããã®å€ããããã®ã§ããã®ãããªãããã·ããããŸãã
ååã«å€§ããªããŒã¿ããŒã¹ãæã€ããªã倧ããªãããžã§ã¯ãããããŸãããç§ãã¡ã¯åžžã«ä»äºãããŠããŸããããµãŒãã¹ã¯èœã¡ãŸããã ç§ãã¡ã¯åºåãé åžããŸãããããªãæ·±å»ãªè² è·ããããã¬ããªã±ãŒã·ã§ã³ã¯ã©ãã§ã䜿çšãããŸãã
ããŒã¿ããŒã¹ã®äž»ãªç¹æ§ã¯ãããã¹ãŠãŸãã¯ç¡ãã®ååãä¿èšŒããããšã§ãã å€æŽã¯å®å šã«çºçãããããŸã£ããçºçããŸããã ããã¯ã©ã®ããã«è¡ãããŸãããããŒã¿ããŒã¹ã¯ã©ã®ããã«ããŒã¿ã®æŽåæ§ãä¿èšŒããŸããïŒ
ããŒã¿ããŒã¹ã«ã¢ã¯ã»ã¹ãããµãŒããŒãRAMããã£ã¹ã¯ãã¯ã©ã€ã¢ã³ãããããŸãã ã¡ã¢ãªã¯ããŒãžã®åœ¢åŒã§ç·šæãããŸãã ããŒã¿ãæŽæ°ããããã®äœããã®ãªã¯ãšã¹ããå°çãããšãããŒãžã¯æåã«RAMã§å€æŽããã次ã«ãã£ã¹ã¯ã«å°éããŸãã
åé¡ã¯ãææ°ã®ããŒããŠã§ã¢ã§ã¯ããã¹ãŠãç¡ãããšããååãäžå¯èœã§ããããšã§ãã ãããã¯äžçã®ç©ççãªéçã§ãã RAMã䜿çšããå Žåã§ãããã©ã³ã¶ã¯ã·ã§ãã«ã¡ã¢ãªã¯Intelã§æè¿ç»å Žããã°ããã§ãã ãããŠããããšäžç·ã«æ®ããæ¹æ³ã¯æ確ã§ã¯ãããŸãã...解決çã¯éèªã§ãïŒ
ç§ãã¡ã¯å¥ã®å Žæ-ãžã£ãŒãã«-ã§ããããããšãæžããŸãã æåã«ãã¹ãŠã®ããŒã¿ããã°ã«æžã蟌ã¿ããã°ããã£ã¹ã¯äžã§ä¿®æ£ãããåŸãã¡ã¢ãªå ã®ããŒã¿èªäœãå€æŽããŸãã ãã®åŸããããããã£ãšåŸã«ããã®ããŒã¿ã¯ãã£ã¹ã¯ã«ä¿åãããŸãã ã€ãŸã éèªã¯å€ãã®åé¡ã解決ããŸãã ããŒã¿ã®äžè²«æ§ã¯æ©èœã®1ã€ã«ãããŸããã
ãã®ã¢ã«ãŽãªãºã ã¯ãPoint In Time RecoveryãŸãã¯PITRãšåŒã°ããŸãã ãªã³ã¯ã«é¢ããæ å ±ã«ç²Ÿéããããšããå§ãããŸãã
ããã¯éåžžã«æçã§ãã
ããŒã¿ããŒã¹ã®éçºè ã«çããäž»ãªè³ªåïŒ
- éèªãæŽçããã«ã¯ïŒ
- æžãæ¹ã¯ïŒ
- ãããå°ãªãæžãæ¹æ³ã¯ïŒ
- ããéãåäœãããæ¹æ³ã¯ïŒ
- ã¬ããªã±ãŒã·ã§ã³ã¯ãããšäœã®é¢ä¿ããããŸããïŒ
ã¬ããªã±ãŒã·ã§ã³ãè¡ãçŽæ¥çãªæ¹æ³ã¯ããã°ããã¹ã¿ãŒããã¹ã¬ãŒãã«ã³ããŒããã¹ã¬ãŒãã«é©çšããããšã§ãã ãžã£ãŒãã«ã¯ãããŒã¿ã®äžè²«æ§ãä¿èšŒããããã«äœ¿çšãããŸãã åãã¡ã«ããºã ãã¹ã¬ãŒãã«é©çšã§ããŸãã ãããŠãã¬ããªã±ãŒã·ã§ã³ãè¡ãããã·ã¹ãã ã«ã¯ã»ãšãã©äœãè¿œå ãããŸããã
PostgreSQLã¯ãŸãã«ãããè¡ããŸãã 圌ã®ãã°ã¯ãå è¡æžã蟌ã¿ãã°ããšåŒã°ããç©ççãªå€æŽãèšé²ã«å ¥ããŸãã ããŒãžã®æŽæ°ã ã¡ã¢ãªå ã«ããŒãžãããããã®äžã«ããŒã¿ããããããã䜿ã£ãŠäœããããŸãã-ãã®éãããã°ã«æžã蟌ã¿ãããããã¹ã¬ãŒãã«æ®ããŸãã
MySQLã«ã¯ããã€ã®ãã°ããããŸããïŒ æ£ããããŸãããã åœåãMySQLã«ã¯ãã°ããŸã£ãããããŸããã§ããã MyISAMãšã³ãžã³ã¯ãããŸããããéèªã¯ãããŸããã
åçã§ã¯ãã¹ãã¬ãŒãžãšã³ãžã³ãšåŒã°ãããã®ãèŠãããšãã§ããŸãã
ã¹ãã¬ãŒãžãšã³ãžã³ã¯ãããŒã¿ããã£ã¹ã¯ã«æžã蟌ãæ¹æ³ãšãããããããŒã¿ãèªã¿åãæ¹æ³ãããŒã¿ãæ€çŽ¢ããæ¹æ³ãªã©ã®åé¡ãæ±ããšã³ãã£ãã£ã§ãã
ãã®åŸãã¬ããªã±ãŒã·ã§ã³ãåºå®ããŸããã ã¬ããªã±ãŒã·ã§ã³ã¯ãå·Šäžã®ããã¯ã¹ã®1è¡-管çãµãŒãã¹ãšãŠãŒãã£ãªãã£ã§ãã
ã¬ããªã±ãŒã·ã§ã³ã«ã¯ãžã£ãŒãã«ãå¿ èŠã§ããã 圌ã¯æžãå§ããŸããã ãã€ããªãã°ãšåŒã°ããŸãã ä»ã®æ¹æ³ã§äœ¿çšããããšãèãã人ã¯ããŸããã§ããã
ã»ãŒåææã«ãMySQLã¯InnoDBãšåŒã°ããæ°ããã¹ãã¬ãŒãžãšã³ãžã³ãçºè¡šããŸããã ããã¯åºã䜿çšãããŠãããã®ã§ãããInnoDBã«ã¯ç¬èªã®éèªããããŸãã InnoDBãšBinary Logãšãã2ã€ã®éèªãèŠã€ãããŸããã ãã®ç¬éã¯æ»ãã®ãªããã€ã³ãã«ãªãããã®åŸã解決ãéåžžã«é£ããåé¡ããããŸããã
ãã€ããªãã°ã¯ãã€ã³ãã€ã³ã¿ã€ã ãªã«ããªã«ã¯äœ¿çšããããInnoDB Undo / Redoãã°ã¯ã¬ããªã±ãŒã·ã§ã³ã«äœ¿çšãããŸããã PostgreSQLã«ã¯1ã€ã®ãžã£ãŒãã«ããããMySQLã«ã¯2ã€ã®ãžã£ãŒãã«ããããŸãããã¬ããªã±ãŒã·ã§ã³ã«å¿ èŠãªãã€ããªãã°ã«ã¯2ã€ãŸãã¯3ã€ã®åœ¢åŒïŒã¿ã€ãïŒããããŸãã
æãç°¡åã«äœæã§ããæåã®ã¿ã€ãã¯ãã¹ããŒãã¡ã³ãããŒã¹ã®ãã€ããªãã°ã§ãã ããã¯äœã§ãã ãã©ã³ã¶ã¯ã·ã§ã³ããšã«é çªã«æžã蟌ãåãªããã¡ã€ã«ã§ãã 次ã®ããã«ãªããŸãã
ãã©ã³ã¶ã¯ã·ã§ã³ã¯ããããã®æŽæ°ãè¡ãããããŒã¿ããŒã¹ã瀺ãããã©ã³ã¶ã¯ã·ã§ã³éå§æå»ã®ã¿ã€ã ã¹ã¿ã³ãã瀺ããããã®åŸãã©ã³ã¶ã¯ã·ã§ã³èªäœãé²ã¿ãŸãã
2çªç®ã®ã¿ã€ãã¯ãè¡ããŒã¹ã®ã¬ããªã±ãŒã·ã§ã³ãšåŒã°ããŸãã ããã¯ããªã¯ãšã¹ãèªäœãæžã蟌ãŸããã®ã§ã¯ãªãããªã¯ãšã¹ããå€æŽããè¡ã§ãããžã£ãŒãã«ã§ãã ç»åã®åãšåŸã®2ã€ã®éšåã§æ§æãããŠããŸãã
åçã§ã¯ãBEFOREç»åãäžã«ãããAFTERç»åãäžã«ãããŸãã
BEFOREã€ã¡ãŒãžã§ã¯ããã©ã³ã¶ã¯ã·ã§ã³ã®åã«ãã£ãè¡ãé 眮ãããŸããã åé€ãããè¡ã¯èµ€ã§ããŒã¯ãããŠããŸãã
ãããã¯äžéšã®BEFOREç»åããã®ãã®ã§ãããäžéšã§ã¯ãªããAFTERç»åã§ã¯åé€ãããŸãã
次ã®å³ã§ã¯ãè¿œå ãããè¡ãç·è²ã§ããŒã¯ãããŠããŸãã
BEFOREã€ã¡ãŒãžãšAFTERã€ã¡ãŒãžã®äž¡æ¹ã«éãUPDATEããããŸãã ãããã¯ã¢ããããŒãã§ãã
ãã®ãœãªã¥ãŒã·ã§ã³ã®åé¡ã¯ãæè¿ãŸã§ãè¡ããŒã¹ã®ã¬ããªã±ãŒã·ã§ã³ã§ã¯ãæŽæ°ããå Žåã§ããã¹ãŠã®åããã°ã«æžã蟌ãŸããããšã§ããã MySQL 5.6ã§ã¯ãããã¯ä¿®åŸ©ãããããã«ããç°¡åã«ãªããŸãã
å¥ã®ã¿ã€ãã®ãã€ããªLog'aããããŸã-æ··åããŒã¹ã ã¹ããŒãã¡ã³ãããŒã¹ãŸãã¯è¡ããŒã¹ãšããŠæ©èœããŸãããåºãé åžãããŠããŸããã
ãããã®éèªã®ã©ããããè¯ãã§ããïŒ
æåã«ããªã¬ãŒã·ã§ãã«ããŒãã«ã«ã€ããŠèª¬æããŸãããã å€ãã®å Žåããªã¬ãŒã·ã§ãã«ããŒãã«ã¯é åã§ãããšèããããŠããŸãã ããã¯2次å é åã§ãããšèãã人ãããŸãã å®éãããã¯ã¯ããã«è€éãªãã®ã§ãã ãã®ãã«ãã»ããã¯ãé åºãæå®ãããŠããªãç¹å®ã®çš®é¡ã®ã¿ãã«ã®ã»ããã§ãã SQLããŒãã«ã«é åºã¯ãããŸããã ããã¯éèŠã§ãã ãŸããçµæãšããŠãããŒã¿ããŒã¹ããSELECT *ãäœæããïŒãã¹ãŠã®ã¬ã³ãŒããã¹ãã£ã³ããïŒãšãã¯ãšãªã®çµæãå€ããå¯èœæ§ããããŸããè¡ã¯1ã€ã®é åºã«ãªã£ãããå¥ã®é åºã«ãªã£ããããŸãã ãããèŠããŠããå¿ èŠããããŸãã
以äžã¯ãã¹ããŒãã¡ã³ãããŒã¹ã®ã¬ããªã±ãŒã·ã§ã³ã§ã¯æ£ããæ©èœããªãã¯ãšãªã®äŸã§ãã
ããŒãã«ããprimary_keyãåé€ããæ°ãããã®-èªåå¢åãè¿œå ããŸããã ãã¹ã¿ãŒãšã¹ã¬ãŒãã®ã¹ãããã®é åºã¯ç°ãªããŸãã ãã®ãããäžè²«æ§ã®ãªãããŒã¿ãåŸãããŸããã ããã¯ãã¹ããŒãã¡ã³ãããŒã¹ã®ã¬ããªã±ãŒã·ã§ã³ã®æ©èœã§ãããããã䜿çšããŠå®è¡ã§ããããšã¯ããŸããããŸããã
ããã¯å ¬åŒã®MySQLããã¥ã¡ã³ãããã®åŒçšã§ãïŒ
å¥ã®ããŒãã«ãäœæããããã«ããŒã¿ã転éããŠãååãå€æŽããå¿ èŠããããŸãã ãã®æ©èœã¯ãæãäºæããªãå Žæã§ãæ®åœ±ãã§ããŸãã
次ã®ã¹ã©ã€ãã¯ãã¬ããªã±ãŒã·ã§ã³ã®åé¡æ¹æ³ã«é¢ããã¬ããŒãã§æãéèŠãªãã®ã®1ã€ã§ãã
PostgreSQLãšåæ§ã«ãã¹ãã¬ãŒãžã¬ãã«ã§ã®äœæ¥ã¯ç©çã¬ããªã±ãŒã·ã§ã³ãšåŒã°ããŸã-ããŒãžãçŽæ¥æäœããŸãã ãŸãããã©ã³ã¶ã¯ã·ã§ã³ã®ååŸã«äžé£ã®ã¿ãã«ãä¿åããè¡ããŒã¹ã®ã¬ããªã±ãŒã·ã§ã³ã¯è«ççã§ãã
ãŸããã¹ããŒãã¡ã³ãããŒã¹ã®ã¬ããªã±ãŒã·ã§ã³ã¯éåžžããªã¯ãšã¹ãã¬ãã«ã§è¡ãããŸãã 圌ãã¯ãããããŸããããããã¯çµãããŸãã...ããããéèŠãªèå³æ·±ãç¹æ§ãç¶ããŸãïŒè¡ããŒã¹ã®ã¬ããªã±ãŒã·ã§ã³ãç§ãã¡ã®ããã«åããšããããªãã¡ è«çè€è£œã®å ŽåãããŒã¿ããã£ã¹ã¯ã«ã©ã®ããã«ä¿åãããŠãããæ£ç¢ºã«ã¯ããããŸããã ã¬ããªã±ãŒã·ã§ã³ãæ©èœããããã«ã¯ãã¡ã¢ãªå ã§ããã€ãã®æäœãå®è¡ããå¿ èŠãããããšãããããŸããã
ãŸããç©çã¬ããªã±ãŒã·ã§ã³ïŒPostgreSQLãInnoDBïŒã¯äž»ã«ãã£ã¹ã¯äžã«ãããMySQLã¬ããªã±ãŒã·ã§ã³ã¯äž»ã«è¡ããŒã¹ãšã¹ããŒãã¡ã³ãããŒã¹ã®äž¡æ¹ã®ã¹ã¬ãŒãäžã«ãããŸãã è¡ããŒã¹ã§ã¯ãè¡ãèŠã€ããŠæŽæ°ããã ãã§æžã¿ãŸãããã¹ããŒãã¡ã³ãããŒã¹ã§ã¯ãã¹ãŠãããã«æªããªããŸãããªã¯ãšã¹ããå®äºããå¿ èŠããããŸãã ããšãã°ã30åéãã¹ã¿ãŒã§èŠæ±ãå®è¡ãããå Žåã30åéã¹ã¬ãŒãã§å®è¡ãããŸãã ããã¯è€è£œã§ãããããã倱æããŸãã
ããã«ãPostgreSQLã¯ãããŒã¿ãŠã§ã¢ããŠã¹ãšãã°ã®2ã€ã®å Žæã§ãã£ã¹ã¯ã«æžã蟌ã¿ãŸãã MySQLã«ã¯ãã¹ãã¬ãŒãžïŒããŒãã«ã¹ããŒã¹ïŒããã°ïŒåãæ¶ã/ããçŽããã°ïŒãããã³ã¬ããªã±ãŒã·ã§ã³ã§äœ¿çšããããã€ããªãã°ã®3ã€ã®å ŽæããããŸãã 1.5å以äžãã£ã¹ã¯ã«æžã蟌ãå¿ èŠããããŸãã MySQLã¯åªããã¢ãŒããã¯ãã£ã§ãããå€ãã®å Žååé¡ããããŸãã
å€ãã®äººãMySQLã¬ããªã«ã«é ãããšã£ãŠããŸãã ã¬ããªã«ãã¬ãŒãã³ã°ã®çç±ãèŠã€ããæ¹æ³ 蚺æã¯å°é£ã§ãã MySQLã«ã¯ããã°ã¹ããŒã¯ãšãªãšåŒã°ãã蚺æããŒã«ããããŸãã éããŠãæãé£ããã¯ãšãªã®ããããèŠã€ããŠä¿®æ£ã§ããŸãã ã¬ããªã±ãŒã·ã§ã³ã§ã¯ãããã¯æ©èœããŸããã çµ±èšåæãå®è¡ããå¿ èŠããããŸã-çµ±èšãèªã¿åãããã«-ã©ã®ããŒãã«ãããé »ç¹ã«äœ¿çšãããããã«ãªããŸããã ãããæåã§è¡ãããšã¯éåžžã«å°é£ã§ãã
MySQL 5.6 / 5.7ã§ã¯ãSLAVE PERFORMANCE SCHEMAãç»å ŽããŸãããããã«åºã¥ããŠããã®ãããªèšºæãããç°¡åã«å®è¡ã§ããŸãã éåžžãããããã§ã³ããããã°ãéããã¬ããªã±ãŒã·ã§ã³ãé ãå§ãããšãã«å±éããå 容ã確èªããŸãã ããã§ã圹ã«ç«ããªãå ŽåããããŸãããã¹ãŠã®éçºè ã«ã¢ã¯ã»ã¹ããŠãã¬ããªã±ãŒã·ã§ã³ãäžæããå Žåã¯äœãããããå°ããå¿ èŠããããŸãã æ²ããããšã§ããããããšäžç·ã«æ®ãããªããã°ãªããŸããã
éåæã¬ããªã±ãŒã·ã§ã³ã«ã¯ãæžã蟌ããã¹ã¿ãŒãšèªã¿åãå°çšã®ã¹ã¬ãŒãããããŸãã ã¹ã¬ãŒãã¯ãã¹ã¿ãŒã«åœ±é¿ãäžããŸããã ãŸããPostgreSQLã§ã¯åœ±é¿ããŸããã MySQLã§ã¯ãæ®å¿µãªããããã§ã¯ãããŸããã èŠæ±ãè€è£œããã¹ããŒãã¡ã³ãããŒã¹ã®è€è£œãæ£ããæ©èœããããã«ãç¹å¥ãªãã©ã°ããããŸãã InnoDBã§ã¯ã泚æããŠãã ãããããªãã¡ ç§ãã¡ã®ã¢ãŒããã¯ãã£ã¯ãäžèšã®ã¬ããªã±ãŒã·ã§ã³ãšã¹ãã¬ãŒãžãšã³ãžã³ãå ±æããŸãã ããããã¹ãã¬ãŒãžãšã³ãžã³ã¯ãã¬ããªã±ãŒã·ã§ã³ãæ©èœããããã«ã倧ãŸãã«èšã£ãŠãããŒãã«ãžã®æ¿å ¥ãé ãããå¿ èŠããããŸãã
å¥ã®åé¡ã¯ããŠã£ã¶ãŒããã¯ãšãªã䞊åã«å®è¡ããããšã§ãã åæã«ãã¹ã¬ãŒãã¯ããããé çªã«é©çšã§ããŸãã åé¡ãçºçããŸã-ãªãã¹ã¬ãŒãã¯ãããã䞊è¡ããŠé©çšã§ããªãã®ã§ããïŒ å®éãããã¯ç°¡åã§ã¯ãããŸããã ã¯ãšãªã䞊åã«å®è¡ã§ããã¿ã€ãã³ã°ãšãé 次å®è¡ããã¿ã€ãã³ã°ã瀺ããã©ã³ã¶ã¯ã·ã§ã³ã·ãªã¢ã«åå®çããããŸãã ããã¯å¥ã®è€éãªãããã¯ã§ããããšãã°ããªã³ã¯http://plumqqz.livejournal.com/387380.htmlãèªãã§èå³ãããå¿ èŠãªå Žåã¯æŽçããŠãã ããã
PostgreSQLã§ã¯ãã¬ããªã±ãŒã·ã§ã³ã¯äž»ã«ãã£ã¹ã¯ã«çœ®ãããŸãã ãã£ã¹ã¯ã¯äžŠè¡ããŠããããã©ãããããã1ã€ã®ã¹ããªãŒã ãæ°ã«ããŸããããšã«ãããäž»ã«ãã£ã¹ã¯ã«åº§ã£ãŠããŸãã CPUãã»ãšãã©æ¶è²»ããŸããã
MySQLã§ã¯ãã¬ããªã±ãŒã·ã§ã³ã¯ããã»ããµäžã«ãããŸãã ããã¯çŸããç»åã§ãã12ã³ã¢ã®å€§èŠæš¡ã§åŒ·åãªãµãŒããŒã§ãã 1ã€ã®ã³ã¢ãæ©èœãããšåæã«ãã¬ããªã±ãŒã·ã§ã³ã§ããžãŒã§ãã ãã®ãããã¬ããªã«ã¯çªæ¯ããŠããŸãã ããã¯ãšãŠãæ²ããã§ãã
ãªã¯ãšã¹ãã䞊è¡ããŠå®è¡ããããã«ããªã¯ãšã¹ãã®ã°ã«ãŒãåããããŸãã InnoDBã«ã¯ããã©ã³ã¶ã¯ã·ã§ã³ã®ã°ã«ãŒãåæ¹æ³ããã©ã³ã¶ã¯ã·ã§ã³ã®ãã£ã¹ã¯ãžã®æžã蟌ã¿æ¹æ³ãå¶åŸ¡ããç¹å¥ãªãªãã·ã§ã³ããããŸãã åé¡ã¯ãããããInnoDBã¬ãã«ã§ã°ã«ãŒãåã§ããããšãšãããé«ãã¬ãã«ïŒã¬ããªã±ãŒã·ã§ã³ã¬ãã«ïŒã§ã°ã«ãŒãåã§ããããšã§ãã 2010幎ãMariaDBã®Christian NelsenãGroup Binary Log CommitãšåŒã°ããæ©èœãå®è£ ããŸãããããã«ã€ããŠã¯åŸã§èª¬æããŸãã Storage Engineãšã¬ããªã±ãŒã·ã§ã³ã®2ã€ã®ã¬ãã«ã§ãžã£ãŒãã«ãç¹°ãè¿ãïŒããã¯ããªãè€éãªããŒã¿æ§é ã§ãïŒãæ©èœãããã¬ãã«ããå¥ã®ã¬ãã«ã«ãã©ãã°ããå¿ èŠãããããšãããããŸãã ããã¯è€éãªã¡ã«ããºã ã§ãã ããã«ã2ã€ã®ãã°ã«åæã«äžè²«ããŠæžã蟌ãå¿ èŠããããŸãïŒ2ãã§ãŒãºã³ãããïŒã ããã¯ããã«æªãããšã§ãã
次ã®å³ã«ã¯ã2ã€ã®ã°ã©ãããããŸãã
éãã°ã©ãã¯ãã¹ã¬ãããè¿œå ãããšãã«InnoDBãã©ã®ããã«ã¹ã±ãŒãªã³ã°ãããã瀺ããŠããŸãã ã¹ã¬ãããé åžããŸã-åŠçãããã©ã³ã¶ã¯ã·ã§ã³ã®æ°ãå¢å ããŸãã
èµ€ãç·ã¯ãã¬ããªã±ãŒã·ã§ã³ãæå¹ã«ãªã£ãŠããããšã瀺ããŸãã ã¬ããªã±ãŒã·ã§ã³ãæå¹ã«ãããšãã¹ã±ãŒã©ããªãã£ã倱ãããŸãã Binary Logã®ãã°ã¯åæçã«æžã蟌ãŸãããããGroup Binary Log Commitã¯ããã解決ããŸãã
äžã®ã¹ãã¬ãŒãžãšã³ãžã³ãäžã®ã¬ããªã±ãŒã·ã§ã³ã®åé¢ã®ããããããè¡ãå¿ èŠãããã®ã¯æ®å¿µã§ãã ããã¯ãã¹ãŠæªãã§ãã MySQL 5.6ããã³5.7ã§ã¯ããã®åé¡ã¯è§£æ±ºãããŠããŸããã°ã«ãŒããã€ããªãã°ã³ããããããããŠã£ã¶ãŒãã¯é ããããšã¯ãããŸããã çŸåšã圌ãã¯ãããã¬ããªã±ãŒã·ã§ã³ã®äžŠååŠçã«äœ¿çšããããšããŠãããããã¹ã¬ãŒãäžã§åãã°ã«ãŒãããã®ãªã¯ãšã¹ãã䞊è¡ããŠèµ·åã§ããŸãã ããããç§ã¯ããªãããããããããå¿ èŠãããããšãæžããŸããïŒ
2013幎10æ以éã倧éã®ããŒã¿ããããããã¬ããªã±ãŒã·ã§ã³ã¯åžžã«é ããŠããã誰ããåæºããŠããŸãããã®äžŠåæ§ã確èªããããšããŸããã ãŸã äœããç解ããŠããªãã£ãã®ããééã£ãèšå®ãããã®ããå€ãã®è©Šã¿ããããçµæã¯æ¬¡ã®ããã«ãªã£ãã®ã§ãããã
éãã°ã©ãã¯MySQL 5.5ã§ãã
y軞äž-ã¹ã¬ãŒãã®ããã»ããµæ¶è²»ã X軞ã¯æéã§ãã
ãã®ã°ã©ãã§ã¯ããã¹ã¿ãŒã«è¿œãä»ãããã«è€è£œãéå§ãããææãšçµäºããææã確èªã§ããŸãã 1ã€ã®ã¹ã¬ããã§5.5ã4ã€ã®ã¹ã¬ããã§5.7ã®äžŠåã¬ããªã±ãŒã·ã§ã³ãšã»ãŒåãããã«æ©èœãããšããèå³æ·±ãç»åãå€æããŸããã ã€ãŸã CPUã¯ããå€ãæ¶è²»ããïŒç·è²ã®ç·ïŒãåãæéã«åäœããŸãã 4ã€ã®ã¹ã¬ããã4ã€ã®ã¹ã¬ããããããŸãã 5.7ã§1ã€ã®ã¹ã¬ãããäœæãããšãåäœãæªããªããŸãã ããã¯äœããã®ãªã°ã¬ãã·ã§ã³ã§ããã5.7.5ã§ä¿®æ£ããããšãæãã§ããŸãããããã§ãã¯ããŸãã-åé¡ã¯ãŸã é¢é£ããŠããŸãã ç§ã®ãã³ãããŒã¯ã§ã¯ãããã¯ããã§ããããã¯æ¬çªç°å¢ã§ã®ãã¹ãã§ãããã§ããããã¯åœç¶ã§ãã 圌ãããããä¿®æ£ããããšãé¡ã£ãŠããŸãã
ä»ã«äœãåé¡ã§ã-ãµãŒãã¹ãåæ¢ããã«ç§»è¡ããã«ã¯ãããæç¹ã§ãMySQL 5.5ããŠã£ã¶ãŒãã§èµ·åããã5.7ãã¹ã¬ãŒãã§èµ·åãããŸãã 5.5ã«ã¯Group Binary Log CommitããããŸãããã€ãŸãã5.7ã¯1ã€ã®ã¹ã¬ããã§ããåäœããŸããã ããã¯ã5.7ã®ã¬ããªã«ãé ãå§ããè¿œãã€ããªãããšãæå³ããŸãã ã·ã³ã°ã«ã¹ã¬ãã5.7ã¬ããªã±ãŒã·ã§ã³ã«ãªã°ã¬ãã·ã§ã³ãããéãã移è¡ããããšã¯ã§ããŸããã5.5ã«åº§ã£ãŠãããããéžæã®äœå°ã¯ãããŸããã
ããã§æãèå³æ·±ãéšåã¯ãç§ãèšã£ãããšãã¹ãŠãšãå¶éæéã®ããã«ã¬ããŒãã«æ®ããããã®ãèŠçŽããããšã§ãïŒ3æéã®è³æããããŸãïŒã
ãŸããã¢ãŒããã¯ãã£ã«ã¯3ã€ã®ã¿ã€ãã®ãã¬ãžã³ããããç©çã¬ãã«ãšè«çã¬ãã«ã§ã®è€è£œããããŸãã ç©çå±€ã¯ããŒãžã§ãã PostgreSQLã¯ãããŒãã«ã®æŽæ°ãããªã¬ãŒã®äœæãã¹ãã¢ãããã·ãŒãžã£ã®äœæãªã©ããã¹ãŠããã°ãééãããã匷åã§ãããããã£ãŠãPostgreSQLã®åé¡ã¯å°ãªãã§ãã MySQLã§ã¯ãæå¹ã«ããã¬ããªã±ãŒã·ã§ã³ã®ã¿ã€ãã«å¿ããŠãè«çã¬ããªã±ãŒã·ã§ã³ãŸãã¯ã¯ãšãªã¬ãã«ã¬ããªã±ãŒã·ã§ã³ãååŸããŸãã
ååãšããŠããããã®éèªã«ã¯é·æãšçæããããããæ éã«éžæããå¿ èŠããããŸãã
ãªã圌ãã¯åŒ·ã/匱ãã®ã§ããïŒ
æåã®è¡ã§ã¯*ã§ãã ç§ã¯èª¬æããŸã-ãšã«ããããã¹ã¿ãŒãããã°ãã³ããŒããå¿ èŠããããããã«ã¹ã¬ãŒãã¯ãã°ãåé€ããªãããã«äœããã®çç±ã§ãã¹ã¿ãŒã«å°ããããšãã§ããŸãã
MySQLã«ã¯2ã€ã®é倧ãªããã«ãã£ãã¹ã¬ãããã¬ããªã±ãŒã·ã§ã³ããŠã£ã¶ãŒãã«äžãã圱é¿ããããŸãã
- ã¹ããŒãã¡ã³ãããŒã¹ã®ã¬ããªã±ãŒã·ã§ã³ãæ©èœããããã®InnoDBã®ãªãã·ã§ã³ã
- Group Binary Log Commitããªããã°ãã¹ã±ãŒãªã³ã°ã¯è¡ãããŸããã
MySQLã®è¡ããŒã¹ã®ã¬ããªã±ãŒã·ã§ã³ã¯ããå¹æçã§ãããåé¡ããããŸãã
次ã«ã奎é·ã PostgreSQLã¯ãã£ã¹ã¯äžã«ãMySQLã¯ããã»ããµäžã«ãããŸãã
ãã£ã¹ã¯æ¶è²»éã®èŠ³ç¹ã§ã¯ãããã§ããèå³æ·±ããã®ã«ãªããŸãã ããšãã°ãMySQLã®è¡ããŒã¹ã®ã¬ããªã±ãŒã·ã§ã³ïŒPostgreSQLã§ã¯ã»ãŒåãïŒã§1æ¥ã«æ°åãã©ãã€ãã®ãã°ãååŸãããŸãããããä¿åãããã£ã¹ã¯ãããŸããªããããã¹ããŒãã¡ã³ãããŒã¹ã«åº§ã£ãŠããŸãã ãããéèŠã§ããã¬ããªã«ãé ããŠããå Žåã¯ããã°ãã©ããã«ä¿åããå¿ èŠããããŸãã ãã®æå³ã§ãPostgreSQLã¯ã¹ããŒãã¡ã³ãããŒã¹ã®ã¬ããªã±ãŒã·ã§ã³ãããæªãèŠããŸãã
ã¹ã¬ãŒãããã»ããµã䜿çšããå ŽåãæååãèŠã€ãããããã¯ãšãªãé©åã«æ©èœããããã«ãã¹ã¬ãŒãã«é©åãªã€ã³ããã¯ã¹ãäœæããããšãéèŠã§ãã ããã¯ããªãå¥åŠãªã¡ããªãã¯ã§ãã ã¬ããªã±ãŒã·ã§ã³å¹çã®èŠ³ç¹ããã¹ã¬ãŒããæé©åããŸãã ã¬ããŒããæ§ç¯ããããã«ã¹ã¬ãŒããå¿ èŠã§ãããã¹ã¬ãŒããã¬ããŒããæ§ç¯ããã ãã§ãªããè¿œãã€ãæéã確ä¿ã§ããããã«èšå®ããå¿ èŠããããŸãã MySQLãã©ã¬ã«ã¹ã¬ãŒã5.6 / 5.7-æåŸ ã«å¿ãããŸã§æ£åžžã«åäœããããšã楜ãã¿ã«ããŠããŸãã
ãã1ã€ã®éèŠãªãããã¯ã¯ãããŒã¿ã®äžè²«æ§ã§ãã
PostgreSQLã¬ããªã«ã¯ããŠã£ã¶ãŒãã®ãã€ããªã³ããŒã§ãã ã€ãŸã æåéã-ãã¹ã¿ãŒã§ã®èšé²ãåæ¢ããã¬ããªã±ãŒã·ã§ã³ãã¹ã¬ãŒãã§çµäºããããã¹ã¿ãŒãšã¹ã¬ãŒãã§ããã»ã¹ãåæ¢ããPostgreSQLãã¹ã¿ãŒãšPostgreSQLã¹ã¬ãŒãã®ãã€ããªæ¯èŒãè¡ããšãããããåãã§ããããšãããããŸãã MySQLã§ã¯ãããã§ã¯ãããŸããã è¡ããŒã¹ã®ã¬ããªã±ãŒã·ã§ã³ã¯ãã¿ãã«ã䜿çšããè«çè¡šçŸã§æ©èœããŸãããã®äžã§ããã¹ãŠã®æŽæ°ãæ¿å ¥ãåé€ãæ£ããæ©èœãããã¹ãŠãæ£åžžã«æ©èœããŸãã
ã¹ããŒãã¡ã³ãããŒã¹ã®ã¬ããªã±ãŒã·ã§ã³ã§ã¯ãããã¯åœãŠã¯ãŸããŸããã ãŠã£ã¶ãŒãã誀ã£ãŠèšå®ããç¹å®ã®ããªãããŒãªã¯ãšãªãå®è¡ãããšãç°ãªãçµæãåŸãããå ŽåããããŸãã ããŒã¿ããŒã¹ã¹ããŒãã§æ©èœããã¯ãšãªïŒããŒãã«ã®äœæãã€ã³ããã¯ã¹ã®äœæãªã©ïŒã®å Žåãããã§ãæ²ãããåžžã«çã®ã¯ãšãªã®ããã«ãªããŸã...ã¹ããŒãã¡ã³ãããŒã¹ã®ã¬ããªã±ãŒã·ã§ã³ã®æ©èœãåžžã«èŠããŠããå¿ èŠããããŸãã
æ··åããŒã¹ã§ã¯ãã¹ããŒãªãŒã¯ããã«èå³æ·±ããã®ã«ãªããŸã-ããã¯ã©ã¡ããã§ããããã¹ãŠãç£èŠããå¿ èŠããããŸãã
æè»æ§ã ã¬ããªã±ãŒã·ã§ã³ã¯ããæè»ã§ãããããMySQLã¯çŸæç¹ã§ã¯æ¬åœã«åªããŠããŸãã ãã¹ã¿ãŒãšã¹ã¬ãŒãã§ç°ãªãã€ã³ããã¯ã¹ãäœæã§ããŸããããŒã¿ã¹ããŒã ãå€æŽããããšãã§ããŸã-å¿ èŠãªå ŽåããããŸãããPostgreSQLã§ã¯çŸåšãã®ãããªå¯èœæ§ã¯ãããŸããã ããã«ãMySQLã«ã¯libslaveããããŸããããã¯éåžžã«åŒ·åãªãã®ã§ãããéåžžã«æ°ã«å ¥ã£ãŠããŸãã ç§ãã¡ã®æªéã¯MySQLã¹ã¬ãŒãã®ãµããããŠãåžžã«ãªã¢ã«ã¿ã€ã ã§æŽæ°ãååŸããŸãã çŽ5ç§ã®é 延ããããŸãã -ãŠãŒã¶ãŒããããŒãèŠããã¯ãªãã¯ãããšã5ç§åŸã«ããŒã¢ã³ããã¹ãŠãéçŽããããŒã¿ããŒã¹ã«èšé²ããŸããã ãããç¥ã£ããããŒãé åžããæªéã PostgreSQLã«ã¯ãã®ãããªããŒã«ã¯ãããŸããã
ãã ããPostgreSQLã¯ä»¥äžãèšç»ããŠããŸãã ãŸããè«çãã°ã¹ããªãŒãã³ã°ã¬ããªã±ãŒã·ã§ã³ãªã©ããããŸããããã¯ãå è¡æžã蟌ã¿ãã°ãå€æããæ¹æ³ã§ãã ããšãã°ããã®ããŒã¿ããŒã¹ãããã¹ãŠã®ããŒãã«ãè€è£œããã®ã§ã¯ãªããäžéšã®ã¿ãè€è£œããå¿ èŠããããŸãã è«çãã°ã¹ããªãŒãã³ã°ã¬ããªã±ãŒã·ã§ã³ã«ããããŠã£ã¶ãŒãã¯ã¹ã¬ãŒãçšã«æ®ãããŒãã«ã説æã§ããŸãã
è«çãã³ãŒãããããŸã-PostgreSQLå è¡æžã蟌ã¿ãã°ã®å 容ãèŠèŠåããæ¹æ³ã å®éãã¹ã¬ãŒãã§äœãèµ·ãã£ãŠããã®ãããŸãã¯Write-Ahead LogãéããŠäœãèµ·ãã£ãã®ããäœããã®åœ¢ã§å°å·ã§ããå Žåãããã¯libslaveãè¡ããã¹ãŠãããã°ã©ã ã§å®è£ ã§ããããšãæå³ããŸãã æ¿å ¥ãæŽæ°ãåé€ãååŸããç®çã®ã³ãŒã«ããã¯ãããžã£ãŒã¯ãããå€æŽã«ã€ããŠåŠç¿ããŸããã ããã¯è«çãã³ãŒãã§ãã
ããããã®çµè«ã¯éåžžã«èå³æ·±ãã§ã-éåžžã®ãžã£ãŒãã«ãäœæããã®ãæåã§ãã PostgreSQLã«ã¯ãéåžžã®ãã°ããã¹ãŠã®ããŒã¿ã®æŽæ°ãã¹ããŒã ã®ãã¹ãŠã®å€æŽãããã³äžè¬çã«ãã¹ãŠã®ãã®ãèšé²ãããŠããŸãã ããã«ãããããšãã°ãæ£ããåäœããã¬ããªã±ãŒã·ã§ã³ãããã»ããµã§ã¯ãªããã£ã¹ã¯äžã«ã®ã¿ååšããã¬ããªã±ãŒã·ã§ã³ãªã©ãå€ãã®å©ç¹ãåŸãããŸãã ãã®ãããªãã¬ãžã³ã䜿çšãããšãç¹å®ã®ãããã»ããããšã³ãžã³èªäœããã¹ã¿ãŒãã¹ã¬ãŒãã«è¿œå ã§ããŸããããã«ãããæè»æ§ãé«ããããšãã§ããŸãã ããŒãã«ããã£ã«ã¿ãªã³ã°ããä»ã®ã€ã³ããã¯ã¹ãæã£ãŠããŸãã
ãããŠæŽå²çãªçç±ãããMySQLã®ãã°ã¯äžè¯ã§ããããšãå€æããŸããã MySQLã¯ãã®æŽå²ççºå±ã®äººè³ªã§ãã MySQLã®åé¡ãããã©ãŒãã³ã¹ãšæ£ç¢ºãã§è§£æ±ºããã«ã¯ãã¹ãã¬ãŒãžãšã³ãžã³ã«é¢é£ä»ããããŠããã¢ãŒããã¯ãã£å šäœãæžãæããå¿ èŠããããŸãããããã¯çŸå®çã§ã¯ãããŸããã
ããªãæéãããããšæããŸãããPostgreSQLã¯æ©èœå¥ã«MySQLããã£ããããŸãã
ãããŠæåŸã«ã ã¬ããŒãå šäœããå€ãã®ããšãç解ããŠããªãå ŽåããŸãã¯ç解ããå¿ èŠãããå Žåã§ãããããã«ããŠãã2ã€ã®æãéèŠãªçµè«ãèŠããŠãããŠãã ããã
- ã¬ããªã±ãŒã·ã§ã³ã¯ããã¯ã¢ããïŒããã¯ã¢ããïŒã§ã¯ãããŸããã
- ããŒãã«ã¯2次å é åã§ã¯ãªããåçš®ã®çµã®ãã«ãã»ããã§ãã ãããã£ãŠãã³ã³ãã¥ãŒã¿ãµã€ãšã³ã¹ã®èŠ³ç¹ããã¯æ£ããã§ãã
ãã®ã¬ããŒãã¯ãç§ãå€ãã®äººã ãäœãã®ã«åœ¹ç«ã¡ãŸããã
é£çµ¡å
ã¶ããããŒã«
ãã®ã¬ããŒãã¯ãé«è² è·ã·ã¹ãã HighLoad ++ã®éçºè ã®äŒè°ã§è¡ãããæé«ã®ã¹ããŒãã®1ã€ã®è»¢åã§ã ã çŸåšã2016幎ã®äŒè°ãç©æ¥µçã«æºåããŠããŸããä»å¹Žã¯11æ7æ¥ãš8æ¥ã«Skolkovoã§HighLoad ++ãéå¬ãããŸãã
è€è£œã®ãããã¯ã¯æ°žé ã§ã:)ä»å¹Žã¯ã2ã€ã®ã¬ããŒãã§äœããã®åœ¢ã§ããã«è§ŠããŸãã
- MySQLã®æºåæ¹æ³ / Nikolay KorolevïŒBadooïŒ;
- MySQL / Sveta Smirnov ã¬ããªã±ãŒã·ã§ã³ã®å¹ççãªãããã° ïŒPerconaïŒã
ãŸãããããã®è³æã®äžéšã¯ãé«è² è·ã·ã¹ãã HighLoadã®éçºã«é¢ãããªã³ã©ã€ã³ãã¬ãŒãã³ã°ã³ãŒã¹ã§äœ¿çšãããŸãã¬ã€ãã¯ãç¹å¥ã«éžæãããæåãèšäºãè³æããããªã®ãã§ãŒã³ã§ãã ç§ãã¡ã®æç§æžã«ã¯ãã§ã«30以äžã®ãŠããŒã¯ãªè³æããããŸãã æ¥ç¶ããŠãã ããïŒ