2017/10/08 phpcon 2017 https://joind.in/event/japan-php-conference-2017/session05-mysqlRead less
PostgreSQLã¨MySQLã使ããªãã©ã£ã¡ï¼Â ãã¼ã¿ãã¼ã¹å°é家ã8ã¤ã®è¦ç¹ã§å¾¹åºæ¯è¼ï¼ ãªã¼ãã³ã½ã¼ã¹ã®ãã¼ã¿ãã¼ã¹ã¨ãã¦ããæ¯è¼ãããPostgreSQLã¨MySQLãã©ããªé·æã»çæãããã®ã§ãããï¼Â ããããã®å°é家ã«ãã対è«ã§æããã«ãã¾ãã ã¨ã³ã¸ãã¢ã¨ãã¦åãã¦ããã¨å¿ ãç´é¢ããæ©ã¿ãããã¯ããã©ã®ãªã¬ã¼ã·ã§ãã«ã»ãã¼ã¿ãã¼ã¹ï¼ä»¥ä¸ãRDBï¼ãé¸ã¶ã®ãæåãªã®ãï¼ãã§ãã RDBãã¨ã«é·æã¨çæã¯ç°ãªã£ã¦ãã¾ãããã®ããèªç¤¾ãµã¼ãã¹ã«ãããããªãRDBãé¸ãã§ãã¾ãã¨ããããããã«ããã¯ã¨ãªãéçºã»éç¨ã«ãã©ãã«ãçããã±ã¼ã¹ã¯å°ãªãããã¾ããã ãªãã§ãããæ¯è¼æ¤è¨ãããã®ããPostgreSQLã¨MySQLãã¨ãã«ãªã¼ãã³ã½ã¼ã¹RDBã®ããã¡ã¯ãã¹ã¿ã³ãã¼ãã§ãããé«ãæ§è½ã¨æ°å¤ãã®æ©è½ãæã£ã¦ãã¾ãã ã§ã¯ã両è ã¯å ·ä½çã«ã©ã®ãããªé·æã»çæãããã®ã§ãããããã
ããã«ã¡ã¯ããµã¼ãã¹éçºé¨ã®èå¼ (@a_bicky) ã§ãã çªç¶ã§ãããRDBMS ã®æ¢åã®ãã¼ãã«ãè¦ã¦ã¿ãããä½ã§ãããªã«ã¤ã³ããã¯ã¹ã ãããªã®ï¼ãã¿ãããªçµé¨ã¯ããã¾ãããï¼ä¸è¦ãªã¤ã³ããã¯ã¹ã¯å®¹éãå§è¿«ããããæ¿å ¥ãé ããªã£ããã¨è¯ããã¨ãããã¾ããã ãããªããã§ãä»åã¯ã¬ã³ã¼ããæ¤ç´¢ããããã«å¿ è¦ãªã¤ã³ããã¯ã¹ã®åºç¤ç¥èã¨ãããè¦ãããä¸é©åãªã¤ã³ããã¯ã¹ã«ã¤ãã¦è§£èª¬ãã¾ããã¯ãã¯ãããã§ã¯ Rails ã®ãã¼ã¿ãã¼ã¹ã¨ãã¦ä¸»ã« MySQL 5.6ãMySQL ã®ã¹ãã¬ã¼ã¸ã¨ã³ã¸ã³ã¨ãã¦ä¸»ã« InnoDB ã使ã£ã¦ããã®ã§ãMySQL 5.6 ã® InnoDB ã«ã¤ãã¦è§£èª¬ãã¾ãã InnoDB ã®ã¤ã³ããã¯ã¹ã«é¢ããåºç¤ç¥è ã¤ã³ããã¯ã¹ã®æ§é (B+ æ¨) InnoDB ã§ã¯ B+ æ¨ã使ããã¦ãã¾ããB+ æ¨ã¯æ¬¡ã®ãããªç¹å¾´ãæã£ãæ¨æ§é ã§ãã 次æ°ã b ã¨ããã¨ã
10. æåéåæåéå US-ASCII æ°åãè±åã32åã®è¨å· JIS X 0201 US-ASCII(ããâãÂ¥ã/ã~ãâãâ¾ã)+ã«ã¿ã« ã JIS X 0208 æ°åãã²ãããªãã«ã¿ã«ããæ¼¢åãã©ãã³æåã ã®ãªã·ã£æåãè¨å·çã JIS X 0213 JIS X 0208 + 第ä¸æ°´æº/第åæ°´æºããã¼ãæ°åã é¼»æ¿é³æåçã 11. æåéåæåéå Windows-31J JIS X 0201 + JIS X 0208 + NECç¹æ®æå + IBM æ¡å¼µæå(ãâ§ããâ §ããã±ããé«ããï¨ããå½ ã ç) Unicode ä¸çä¸ã®æåãçµµæå(ã�����������������ãã�������������������ãç)ãå«ãã
å æã詳解MySQL 5.7ãçºåããã°ããã§ããããMySQL 5.7èªä½ã¯å»å¹´ã®10æã«ãªãªã¼ã¹ããããã¼ã¸ã§ã³ã§ãããããããç´1å¹´å¼±ãMySQLã¯éçºã®æãç·©ãããã¨ç¡ãæ¥ã æ¹è¯ãéãã¦ããã ãããMySQL 8.0ã®ç»å ´ã§ããã ç¾å¨ã¯Development Milestone Releaseï¼é称DMRï¼ã¨ããç¶æ ãªã®ã§ãã¾ã æ£å¼çã«ãããæ©è½ãåºã¾ã£ã¦ãã段éã§ã¯ãªãã¨ããç¹ã«ã¯æ³¨æãã¦æ¬²ãããMySQLã®éçºããã»ã¹ã§ã¯ãDMRããªãªã¼ã¹ãããã¨ã«ãã®æ®µéã§æçããæ©è½ããã¼ã¸ãããDMRãä½åº¦ããªãªã¼ã¹ããå¾ã«ãããªã®è¯ãã¨ããã§ãªãªã¼ã¹åè£çã¨ãªã£ã¦æ£å¼çã§è¿½å ãããæ©è½ãä¸å¿ç¢ºå®ãããã®å¾ãã°ä¿®æ£ãçµã¦æ£å¼çï¼GAçï¼ããªãªã¼ã¹ãããäºå®ã¨ãªã£ã¦ããã詳ããã¯MySQLã®ããã¥ã¢ã«ãåç §ãã¦æ¬²ããã ãã¼ã¸ã§ã³8.0!!5.7ã®æ¬¡ã¯èª°ãã5.8ã ã¨æã£ã¦ããã ããã»
"Nested Loop Joinããåãä¸ãã¦ç¡ãã®ã«ã¿ã¤ãã«ã大ããããªãã" ã¨ææãé ããã®ã§ãã¿ã¤ãã«ãä¿®æ£ãã¾ãããMerge Joinã¨Hash Joinã®ãã¨ã¯ã¾ãä»åº¦æ¸ããã¨æãã¾ãã ãJOINã¯é ããã¨ããè¨ããã¾ããç¹ã«RDBã使ãå§ãã¦éããªãå ã«ããããè¨èª¬ã«è§¦ããçµæãJOIN=æªãã¨ããèªèã§åºå®åããã¦ãã¾ã£ã¦ãã人ãå¤ãããã«æãã¦ãã¾ãã ãããã«ãJOINãå«ããããªSELECTæã¯ãå«ã¾ãªããã®ã«æ¯ã¹ã¦éãããªãå¾åããããã¨ã¯äºå®ã§ããã¾ããæ¬è³ªçã«åãåããããå 容ãè¤éã§ã対å¦ãããã¨ãé£ãããã®ãåå¨ãã¾ããããããRDBã®ä¸ã§ä¸ä½ã©ããããã¨ãèµ·ãã¦ããã®ããç¥ããããã«åºãã¦å¯¾å¦ããã°é«éåã§ãããã¨ãå°ãªããªãã¨èãã¦ãã¾ãã æ¬ç¨¿ã§ã¯ãJOINã®å é¨åä½ã解説ããä¸ã§ãWebãµã¼ãã¹ãä½ã£ã¦ããã¨ããåºã¦ããJOIN SQLãä¾é¡ã«
ä»å¹´ã®5æ1æ¥ã«ãä»å°å¸å ã®ããã«ã§å¤éäºç´ã®ãã©ãã«ãçºçããã¨å ±éããã¦ãã¾ãã é¨å±æ°ï¼ï¼ï¼å®¤ã®ä»å°å¸ã®ãã¸ãã¹ããã«ã§ãï¼æï¼ï¼ï½ï¼ï¼æ¥ã®å®¿æ³äºç´ãæ°å件åãä»ãããã©ãã«ããã£ããã¢ã¤ãã«ã°ã«ã¼ããåµãã®ã©ã¤ããå®®åçå ã§éå¬ãããæéã ã£ããã¤ã³ã¿ã¼ãããã§ã®ç³ãè¾¼ã¿ã殺å°ããã·ã¹ãã é害ãèµ·ããã¨ã¿ãããã¨ããã ãã©ãã«ããã£ãã®ã¯ãä»å°å¸æ³åºã®ãããã«ã«ã¼ãã¤ã³ä»å°æ³ã¤ã³ã¿ã¼ããããã«ãªã©ã«ããã¨ãï¼æï¼ï¼ãï¼ï¼ãï¼ï¼ãï¼ï¼æ¥ã«å®®åã¹ã¿ã¸ã¢ã ï¼å®®åçå©åºçºï¼ã§åµãã©ã¤ããéããã¨ãæããã«ãªã£ãå¾ã®ï¼æï¼æ¥ååï¼æããããããã使ã£ãäºç´ç³ãè¾¼ã¿ã殺å°ãã¦ãããã¨ã«æ°ã¥ããã¨ããã ï¼ï¼ï¼å®¤ã®ããã«ãªã®ã«ãäºç´ãæ°å件ãåµå ¬æ¼ã§æ®ºå°ãï¼ææ¥æ°èãã¸ã¿ã« ããå¼ç¨ 5æ1æ¥ã®æã«ä½ããã£ãã®ã調ã¹ã¦ã¿ãã¨ããã®æ¥ã®æ©æã«ãã¬ããæ°èã§ã³ã³ãµã¼ãã®æ å ±ãæµããããã§ããã ã
ããã®ã¨ãããjavaccã¨awsã«é äºããã¦ããç±³æã§ãã ãã使ãDB(Oracle/MySQL/PostgreSQL/SQLServer)ã«ãããè¨è¨æã®ãµã¤ãºè¦ç©ããã§ä½¿ããµã¤ãã®åå¿é²ã ãã¨ã¯ãOracleããã®Pythonæ å ±ã Oracle Oracle ç©çè¨è¨ http://www.oracle.com/technology/global/jp/columns/skillup/oracle9i/index.html é åãµã¤ãºè¦ç©ãã http://otn.oracle.co.jp/document/estimate/index.html OTNã«ãã°ã¤ã³ããå¿ è¦ããã¾ãããªã³ã©ã¤ã³ã§è¦ç©ãããåºæ¥ã¾ãã ã¢ã«ã¦ã³ãæã£ã¦ããªã人ã¯ããã®è¦ç©ãããã¼ã«ã使ãç®çã§ã¢ã«ã¦ã³ããä½ã£ã¦ã¿ã¦ã¯ãããã§ããããã OLTPç³»ã¨DWHç³»ã«ããã¦ãããã¯ãµã¤ãºãèæ ®ããDWHç³»ã¯ã
以åãMySQLãé«éåãã10ã®æ¹æ³ã¨ããæ稿ã§ãEXPLAINã®è¦æ¹ã«ã¤ãã¦ã¯ããã解説ãããã¨æããã¨æ¸ãã¦ãã¾ã£ãã®ã§ãä»æ¥ã¯ãã®å ¬ç´ï¼ãæãããã¨æãã MySQLã®ãã¥ã¼ãã³ã°ã§æã大åãªã®ã¯ãã¯ã¨ãªã¨ã¹ãã¼ãã®æé©åã§ãããã¹ãã¼ãã®è¨è¨ã¯ä¸åº¦æ±ºãã¦ãã¾ãã¨ãã®ãã¼ãã«ãå©ç¨ããå ¨ã¦ã®ã¯ã¨ãªã«å½±é¿ãã¦ãã¾ããããªããªãå¤æ´ãããã¨ã¯åºæ¥ãªãããã¯ã¨ãªã¯ãã®ã¯ã¨ãªã ããæ¸ãç´ãã°è¯ãã®ã§å¤æ´ã®æ·å± ã¯ä½ããããã¦é ãã¯ã¨ãªããªãããã¨ã¯ãæ§è½ãå¤§å¹ ã«åä¸ãããããã®æãæå¹ãªæ段ã§ãããå¾ã£ã¦ãã¢ããªã±ã¼ã·ã§ã³ã®æ§è½ãåä¸ãããããªããã¾ãæåã«ã¯ã¨ãªã®ãã¥ã¼ãã³ã°ãæ¤è¨ããã¹ããªã®ã§ããã æé©åããã¹ãã¯ã¨ãªã¯ã¹ãã¼ã¯ã¨ãªãã°ãã¯ã¨ãªã¢ãã©ã¤ã¶ã§è¦ä»ããããããã§ã¯ãã®ãããªã¯ã¨ãªãè¦ã¤ãã£ãå ´åã«ã¯ã©ã®ããã«æé©åããã°ããã®ãï¼ãã®ããã«ã¯ã¾ãç¾å¨ã©ã®ããã«ã¯ã¨ãªãå®è¡ã
MySQL㧠geometry åã®ã«ã©ã ã«ä½ç½®æ å ±ãæ ¼ç´ããéã«ããã£ã¦ãã¾ã£ãã®ã§ã¡ã¢ã MySQLã«ç·¯åº¦çµåº¦ãæ ¼ç´ããããæ¹ã¨ãã¦ã¯ãGoogle Mapsã¨MySQLã®é£æº : ã¢ã·ã¢ã«ããã°ãã®èª¬æã詳ããã®ã§ãããgeometryåã使ãã¨ä¾ãã°ä»¥ä¸ã®ãããªSQLã§ã«ã©ã ãæ´æ°ãããã¨ã«ãªãã¾ãã UPDATE landmarks SET latlng=GeomFromText('POINT(139.751892 35.705637)') WHERE id=100 ã§ããã®ã¨ãããã£ã¦ãã¾ã£ãã®ã POINTã®å¼æ°ã«ã¯ã³ã³ããä¸è¦ ã ã¨ãããã¨ã x座æ¨ãy座æ¨ãå¼æ°ã«ã¨ã£ã¦ããã®ã§ä½ãèããã«ã³ããå ¥ãã¦ãã¾ã£ã¦ããã®ã§ãããSQLãå®è¡ãã¦ãä½ãã¨ã©ã¼ãåºãªãä¸ã«å¤ãæ´æ°ãããªããããè¦ãã¨æ£ããã¯ã¹ãã¼ã¹åºåãã ã£ãã¨ãããªãã ãMySQL :: MySQL 4.1 ãª
MySQL 5.6ç»å ´ï¼ï¼æ°æ©è½éæ»ã¬ãã¥ã¼ - æ¼¢(ãªãã³)ã®ã³ã³ãã¥ã¼ã¿é ãè¦ã¦ããããMySQL5.6ã®æ°æ©è½ã®ï¼ã¤ã¨ãã¦ããããªç´¹ä»ãã OpenGIS ã¸ãªã¡ããªãã¼ã¿ã®æ¯è¼ã«ããã¦ãããã¾ã§ã¯MBRï¼minimum bounding rectangle â è¿ä¼¼çãªé·æ¹å½¢ï¼ã«åºã¥ããæ¯è¼ããåºæ¥ãªãã£ãã®ã ããã¸ãªã¡ããªã®æ£ç¢ºãªå½¢ã«åºã¥ããæ¯è¼ãã§ãããã¼ã¸ã§ã³ã®é¢æ°ã追å ããããä¾ãã°MBRãã¼ã¸ã§ã³ã®Contains()ã«å¯¾ãã¦ãST_Contains()ã¨ããããã«ãST_ã¨ãããã¬ãã£ãã¯ã¹ã®ã¤ãããã®ãæ£ç¢ºãªæ¯è¼ããããã¼ã¸ã§ã³ã¨ãªãã ã¤ã¾ããï¼ç§ã使ã£ããã¨ããªãï¼postGISããããã使ããªãã¦ãã使ãæ £ããMySQLã ãã§ããã®é¨åã®è¨é²ãæ¢ãããï¼ãã¨ããè¦æ±ã«ç°¡åã«çãããããã§ãããã£ããæ©è½ãä½ã£ã¦ã¿ã¾ããã å®éã¯4/22ããæ¤è¨éå§ãã¦ãä»æ¥ã
2012å¹´7æ1æ¥ã®ãããç§ã®ãã¨ã«ãMySQLãJavaãªã©ã®CPU使ç¨çãé«é¨°ããäºè±¡ãå ±åããã¦ãã¾ãã CPU %user %nice %system %iowait %steal %idle 08æ30å01ç§ all 0.02 0.00 0.02 0.04 0.00 99.91 08æ40å01ç§ all 0.02 0.00 0.02 0.08 0.00 99.88 08æ50å01ç§ all 0.02 0.00 0.02 0.03 0.00 99.92 09æ00å01ç§ all 0.11 0.00 0.13 0.04 0.00 99.72 09æ10å01ç§ all 23.02 0.00 29.09 0.11 0.00 47.78 09æ20å01ç§ all 23.11 0.00 29.08 0.06 0.00 47.75 09æ30å01ç§ all 22.85 0.00
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}