ãããã¤ã³ã¹ãã¼ã«ä»£è¡¨ã®ã©ã¤ãããã¯ããã°
MySQL ã«éãããSQL ã®NULL ã®ä»æ§ã«ã¯ä½åãããã£ãã¨é©ããã¨ããã£ãã®ã§ã¡ã¢ãã¦ãããã¨æãã¾ãã5.1 çã®æ¥æ¬èªããã¥ã¢ã«ããªãã£ããã®ã«ã¤ãã¦ã¯ã4.1 ã®ããã¥ã¢ã«ãåç §ãã¾ããã ããããNULL ã¯ä½ãæå³ããã NULL ã¯æªå®ç¾©ã¾ãã¯ãä¸æãæå³ããããé»è©±çªå·ãæããªããã¨ãããã¨ã表ç¾ããå ´åã¯ãNULL ã§ã¯ãªãã空ã®æååã使ãã NULL å¤ã¨ãããã®ã SQL åå¿è ã¯ããæ··ä¹±ãã¾ããSQL åå¿è ã¯ãå¤ãã®å ´åãNULL ã空æå "" ã¨åãã§ããã¨èãã¦ãã¾ãã¾ããããã¯éãã¾ãããã¨ãã°ã以ä¸ã®ã¹ãã¼ãã¡ã³ãã¯å®å ¨ã«å¥ã®ãã®ã§ãã mysql> INSERT INTO my_table (phone) VALUES (NULL); mysql> INSERT INTO my_table (phone) VALUES (""); ã©ã¡ãã®ã¹
Webãµã¼ãã¹ã§ã¯ãä¸çä¸ããã®ãã©ãã£ãã¯ãæãå¿ è¦ããããããããããã¥ã¼ãã³ã°ãããã¨ãä¸å°ã®RDBMSã§ã¯æããããã¨ãåºæ¥ãªãã®ã常ã ãMySQLã¯æåãããã¹ã¿ã¼ã»ã¹ã¬ã¼ãåã®ã¬ããªã±ã¼ã·ã§ã³æ©è½ãæè¼ããã¦ãããã¹ã¬ã¼ããããããã¶ãä¸ãããã¨ã«ãã£ã¦åç §ã®è² è·ãã¹ã¬ã¼ãã«å²ãæ¯ãã¨ããã¹ã±ã¼ã«ã¢ã¦ãã«ãã£ã¦ãã®åé¡ã«å¯¾å¦ãã¦ãããã¹ã¬ã¼ãã«ããã¹ã±ã¼ã«ã¢ã¦ãã¯ãåç §ï¼ï¼PVï¼ãå¤ãWebãµã¤ãã¨é常ã«ç¸æ§ãè¯ããå¹¾å¤ã®Webãµã¤ãã«ããã¦å®ç¸¾ãä½ã£ã¦ãã¦ããããã¾ã ã¾ã å©ç¨ããã¦ããã ããããªããããµã¤ãã®ãã©ãã£ãã¯ãåçã«å¢å ãã¦ããããã«ãªãã¨ãã¬ããªã±ã¼ã·ã§ã³ã«ããè² è·åæ£ã§ã¯è¿½ãã¤ããªããªã£ã¦ãããããã§äººã ãã¨ã£ãé¸æè¢ã¯ãmemcachedãå©ç¨ãããã¨ã§ãããmemcachedã¯ã¤ã³ã¡ã¢ãªåã®é«éãªKVSã§ãããåç §ã»æ´æ°æ§è½ã¯MySQLããæ ¼æ®µã«é«ããM
SlowLogã®è¨å® ç°å¢è¨å®ãã¡ã¤ã«(Windowsã§ã¯my.iniï¼Linuxã§ã¯my.cnf)ã«æ¬¡ã®ãããªè¨å®ãå ããã¨SlowLogãæå¹ã«ãªãã log-slow-queries SlowLogã®æå¹å(ãã°ãã¡ã¤ã«åãæå®å¯è½) long-query-time=2 SlowLogã«è¨é²ããå¦çæéã®ä¸é log-long-format ã¤ã³ããã¯ã¹ã使ç¨ããªãSQLæã®è¨é² long-query-timeãã©ã¡ã¼ã¿ã¯ï¼SlowLogã«è¨é²ãããããå¤ãç§åä½ã§è¨å®ããããã®å ´åã«ã¯ï¼2ç§è¶ ããå¦çæéãè²»ãããSQLæãè¨é²ãããã¾ãï¼log-long-formatãæå®ããã¨ï¼ã¤ã³ããã¯ã¹ã使ç¨ããªãSQLæãSlowLogã«è¨é²ããã SlowLogã®ç¢ºèª SlowLogãåä½ãã¦ãããã©ããã¯ï¼æ¬¡ã®ã³ãã³ãã§ç¢ºèªã§ãããlog_slow_queriesãONã§ããã°æå¹ã¨
ãã¤ããMySQLã使ãã¨ãã¯ããããã¹ããã¨ãã観ç¹ããè¨äºãæ¸ãã¦ããããä»æ¥ã¯éã«ç¯ãã¦ã¯ãããªãéã¡ããªã¹ãã¢ãããããã¨æãã 1. å ¨ã¦ã®ã«ã©ã ã«ã¤ã³ããã¯ã¹ãã¤ãããã¼ã¿ãã¼ã¹åå¿è ããã£ã¨ããã£ã¦ãã¾ããã¡ãªééãã¯ã³ã¬ã§ã¯ãªãã ããããã¤ã³ããã¯ã¹ã¯ãããæ¤ç´¢ãã¨ã¦ãéããªããããããããããã¨å¼ãæ¿ãã«ã¤ã³ããã¯ã¹ã¯æ´æ°ããã¨ãã«ã³ã¹ããããããããã®åå¤ãã®ãã£ã¹ã¯ã¹ãã¼ã¹ãæ¶è²»ãããç¹ã«æ´æ°ã«ãããã³ã¹ãã¯æã«ç大ã§ã該å½ããã¤ã³ããã¯ã¹ã®ãã¼ã¸ããã£ãã·ã¥ä¸ã«ãªãå ´åã¯ãã£ã¹ã¯ãããã£ãããã®ãã¼ã¸ãèªã¿è¾¼ã¾ãªããã°ãããªãããã£ã¹ã¯ã¢ã¯ã»ã¹ã¯åä½ã«ã¨ã¦ãæéããããã®ã§ãã¤ã³ããã¯ã¹ãå¤æ°ãä¾ãã°å ¨ã¦ã®ã«ã©ã ã«ä»ãã¦ãããããã¨ãããï¼åºã¾ã£ããï¼ãã¨ãããããªç¶æ ã«ãªã£ã¦ãã¾ããã¨ãããã ãããã¤ã³ããã¯ã¹ã¯å¿ è¦ãªã«ã©ã ã«ã ãã¤ããããã«ãã¼ãã«ãè¨è¨ãããã
ããMySQLã¯ãµãã¯ã¨ãªãå¼±ãã¨è¨ãããããããã¯æ¬å½ã ãããï¼ååã¯æ¬å½ã§ååã¯åã§ãããMySQLã®ãµãã¯ã¨ãªã ã£ã¦ãªãã§ãããã§ãé ãããã§ã¯ãªããè½ã¨ãç©´ããã£ããé¿ãã使ãã©ãããééããªããã°ãµãã¯ã¨ãªãé«éã«å®è¡ã§ããã®ã§ãããä»æ¥ã¯MySQLãã©ããªé¢¨ã«ãµãã¯ã¨ãªãå®è¡ããã©ã®ãããªå ´åã«é ãã®ãã¨ãããã¨ã«ã¤ãã¦èª¬æãããã EXPLAINã§å®è¡è¨ç»ã調ã¹ãéã«ãselect_typeã«ã¯ã¯ã¨ãªã®ç¨®é¡ã表示ãããã®ã ãã代表çãªãµãã¯ã¨ãªã«ã¯æ¬¡ã®3ã¤ã®ãã¿ã¼ã³ãããã SUBQUERY DEPENDENT SUBQUERY DERIVED çµè«ããè¨ãããé ãã®ã¯2çªç®ãDEPENDENT SUBQUERYã§ãããDEPENDENT SUBQUERYã¨ã¯ããããç¸é¢ãµãã¯ã¨ãªã«ç¸å½ãããã®ã§ããµãã¯ã¨ãªã«ããã¦å¤é¨ã¯ã¨ãªã®ã«ã©ã ãåç §ãã¦ãããµãã¯ã¨ãªã®ãã¨ã§ããããã
MySQLãé«éåãã10ã®æ¹æ³ã¨ããè¨äºãã¨ã¦ã好è©ã ã£ãããã§ãããè¨äºãèªãã§é ããçããããããã¨ãã ãã®è¨äºã«å¯¾ãã便ä¹ï¼ï¼ï¼ã§Webå±ã®ãã¿å¸³: PostgreSQLãé«éåãã16ã®ãã¤ã³ãã¨ããè¨äºãæ¸ãã¦é ããããã ãããã¡ãã®æ¹ãããªã人æ°ã ã£ãããã§ãããä»äººãä½ã£ãã½ããã¦ã§ã¢ã«æ¹è¯ãå ããã¨ããããªã¼ã½ããã¦ã§ã¢ããªã¼ãã³ã½ã¼ã¹ã½ããã¦ã§ã¢ã®ç²¾ç¥ãåºæ¬ã¯ä¾¿ä¹ã§ããã®ã§ã便ä¹ã«ã¤ãã¦ã¯å¤§ãã«è³æãããã¨ããããããåãä¸ãã¦ããã¦ãããã¨ãï¼ï¼ã¨æãããã§ããããããã§ããã«ä¿ºã¯ããèããã ã¨ã Webå±ã®ãã¿å¸³ããã®è¨äºã§ã¯16ã®ãã¤ã³ããç´¹ä»ããã¦ããããæ¼¢ï¼ãªãã³ï¼ã®ã³ã³ãã¥ã¼ã¿éã®è¨äºã¯10ã®æ¹æ³ã ã£ãã®ã§ãã¨6ã¤è¶³ããªãããªãã³ã¯æ°ã§åè² ï¼ï¼ã¨ããããã§ä»æ¥ã¯ãã¿ãæ¯ãçµã£ã¦ããã«7ã¤ã®MySQLé«éåãã¯ããã¯ãç´¹ä»ãããã 1. ã¤ã³ãã«ã³ã³ãã¤ã©
ã¡ãã£ã¨ãã£ããâãªã¿ã¤ãã«ãã¤ãã¦ãã¾ã£ãããä»æ¥ã¯ç¬æã¨åè¦ã§MySQLãé«éåããæ¹æ³ã10åç´¹ä»ããããMySQLãµã¼ãããã¥ã¼ãã³ã°ããã¨ããåæå°å ¥ããå ´åãªã©ã«åèã«ãã¦ãããããã 1. ãããã¡ãå¢ãããã¾ãã¯æ¸ãã ãã¥ã¼ãã³ã°ã®åºæ¬ä¸ã®åºæ¬ã§ããããé©åãªãããã¡ãµã¤ãºãè¨å®ãããã¨ã¯ããã©ã¼ãã³ã¹ãã¥ã¼ãã³ã°ã®è¦ã§ããã主ãªãããã¡ã¯æ¬¡ã®éãã innodb_buffer_pool_sizeã»ã»ã»InnoDBã ããå©ç¨ããå ´åã¯ç©ºãã¡ã¢ãªã®7ã8å²ç¨åº¦ãå²ãå½ã¦ãæãéè¦ãªãããã¡ã§ãããä½è«ã ããå®éã«ã¯ããã§å²ãå½ã¦ãå¤ã®5ã10%ããããå¤ãã«ã¡ã¢ãªã使ãã®ã§æ³¨æãå¿ è¦ã ã key_buffer_sizeã»ã»ã»MyISAMã ããå©ç¨ããå ´åã¯ã空ãã¡ã¢ãªã®3å²ç¨åº¦ãå²ãå½ã¦ãã¨ãããæ®ãã¯ãã¡ã¤ã«ã·ã¹ãã ã®ãã£ãã·ã¥ç¨ã«æ®ãã¦ãããã sort_buffer_
æè¿ã®Webãµã¼ãã¹éçºã§ã¯ãªã¼ãã³ã½ã¼ã¹ã®ãã¼ã¿ãã¼ã¹ãå©ç¨ãããã¨ãå¤ããªã£ã¦ãããããã ãä¿¡é ¼æ§ãå®å®æ§ãåä¸ãã¦ããã¨ãããã¨ã ããã以åã¯PostgreSQLã®æ¹ã人æ°ããã£ãããæè¿ã§ã¯MySQLãé¸ã°ããæ¹ãå¤ãããã ã mk-parallel-dumpã®ãã«ã ããããä¸ã§ãå¿ è¦ã«ãªã£ã¦ããã®ãMySQLã®ç®¡çãã¼ã«ã ãç¹ã«è¦æ¨¡ã®å¤§ããªéçºãé²ããä¸ã§ãããã©ã«ãã®ãã¼ã«ã ãã§ã¯ç©è¶³ããªãã¨æãã¦ãã人ã¯ããã¡ãã®ããã«æ´ç·´ããããã¼ã«ã使ã£ã¦ã¿ããã ä»åç´¹ä»ãããªã¼ãã³ã½ã¼ã¹ã»ã½ããã¦ã§ã¢ã¯MaatkitãMySQLåãã®ã³ãã³ãã©ã¤ã³ãã¼ã«ç¾¤ã ã Maatkitã¯Perlã§ä½ãããã½ããã¦ã§ã¢ã§ãMySQLã®é«åº¦ãªæä½ãå¯è½ã«ãããã¼ã«ãå¹¾ã¤ãæä¾ããã¦ããããããã¯mk-ã§ã¯ãã¾ãååã®ã³ãã³ãåã«ãªã£ã¦ãããå·çæç¹ã§ã¯19ã®æ©è½ãããã ã³ãã³ãä¸è¦§ 主ãªã³ãã³
Railsã§ã¯ããã¼ã¿ãã¼ã¹ã®è¨å®ãMigrationãã¡ã¤ã«ã«æ¸ãã¦ãã£ã¦ãå³åæ ãããªããéçºãéãã¦ããããã®ããã幾人ãã§éçºãè¡ã£ã¦ããã¨ãå¾ã ã«ãã¼ã¿ãã¼ã¹æ§é ãè¤éåããæé©åããã¦ããªãæ§é ã«ãªã£ã¦ãã¾ããããã¯Railsã«éãããã·ã¹ãã éçºã§ã¯å¸¸ã«çãããã®ã ããã ã¡ã¤ã³ç»é¢ åæã®é ãããã¹ã¦ãæ³å®ãã¦ä½ãä¸ãã¦ãããã¨ã¯é£ããããããã¿ã¤ãã³ã°ã§æ£è¦åãã¦ããå¿ è¦ãçããã ããããã®æã«å½¹ç«ã¤ã®ããã®ã½ããã¦ã§ã¢ã ã ä»åç´¹ä»ãããªã¼ãã³ã½ã¼ã¹ã»ã½ããã¦ã§ã¢ã¯MySQL WorkbenchãMySQLã®ãã¼ã¿ãã¼ã¹ãã¶ã¤ãã¼ã ã MySQL Workbenchã¯ãããã¼ã¿ãã¼ã¹ã«é¢ãã¦ãã¼ãã«ããã¥ã¼ãã«ã¼ãã³ãSQLã¹ã¯ãªããçããã¸ã¥ã¢ã«çã«è¨è¨ã§ããããã¤ã¢ã°ã©ã ãä½æã§ããæ¢ã«ä½æããã¦ãããã¼ãã«ããã¥ã¼çããã©ãã°ã¢ã³ãããããã§é ç½®ããããã«ç·ãå¼ã
æ¥æ¬ã§ããªã¼ã®ãã¼ã¿ãã¼ã¹ã»ãµã¼ãã¨ããã°PostgreSQLãæ¯é çã§ãããMySQLã¯æ°¸é ã®äºçªæã¨ããå°è±¡ãããã¾ãã ä¾ãã°ã@ITã®Linux Squareã«ããã第2åãèªè 調æ»çµæçºè¡¨ï¼2000/12/12ï¼ã«ããã°ã Webé£æºã³ãã¥ãã±ã¼ã·ã§ã³ã§ã¯ï½¤PostgreSQLã®ä¸äººåã¡ Webé£æºæ¥åã·ã¹ãã ã§ã¯ãPostgreSQLã¨Oracleãã·ã§ã¢ãäºã ã ããã§ãã 確ãã«ãäºå¹´åã¯ãããªããã§ãããããæ¥æ¬èªåãå¾çºã¨ãªã£ã¦ãã¾ã£ãMySQLãç¾å¨ã·ã§ã¢ã伸ã°ãã¤ã¤ããããã§ãã amazon.co.jpã§æ¤ç´¢ããã¨PostgreSQLã¯19件ãMySQLã¯10件ã®æ¸ç±ãæ¤ç´¢ããã¾ããï¼ã¡ãªã¿ã«Oracleã¯112件ã§ããï¼ï¼2002/10/20ï¼ã â»2004å¹´8æ20æ¥ç¾å¨ãPostgreSQLã¯31件ãMySQLã¯25件ãOracleã¯181件ã§ã
Apache/PHP/MySQL/SQLite/SQLiteManage/PhpMyAdmin/Zend OptimizerãWindowsã«ã¾ã¨ãã¦ãªã¼ã«ã¤ã³ã¯ã³ã§ã¤ã³ã¹ãã¼ã«ãããã¨ãã§ããããã«ãªã£ã¦ããã®ããªã¼ãã³ã½ã¼ã¹ã§éçºããã¦ãããã®ãVertrigoServãã ãããã®åã½ããã«ã¤ãã¦ç°¡åã«è¨å®ãå¤æ´ã§ããã³ã³ããã¼ã«ããã«ã£ã½ããã®ãã¿ã¹ã¯ãã¬ã¤ããä¸çºã§å¼ã³åºããããã«ãªã£ã¦ãããé常ã«è¨å®ãç°¡åã§ããã¾ããã¤ã³ã¹ãã¼ã©ã¯æ¥æ¬èªåããã¦ããã®ã§å®å¿ã§ãã å®éã®ã¤ã³ã¹ãã¼ã«æ¹æ³ãªã©ã¯ä»¥ä¸ããã VertrigoServ http://vertrigo.sourceforge.net/ ãã¦ã³ãã¼ããããå®è¡ãã¾ã ãOKããã¯ãªã㯠ã次ã¸ããã¯ãªã㯠ãåæããããã¯ãªã㯠ã次ã¸ããã¯ãªã㯠ããã«ã次ã¸ããã¯ãªã㯠ãã¤ã³ã¹ãã¼ã«ããã¯ãªã㯠ã¤ã³ã¹ãã¼ã«ä¸â¦â¦
ãããããªæ¬ããã¡ã¢ã£ã¦ããã¡ã¢ã®ã¡ã¢ãåºå ¸ãæ¸ãã¦ããã®ãå¿ãããæãåºã次第è£å®ããããã deleteã®ã³ã¹ãã¯é«ãã®ã§ãç¡å¹åã示ããã£ã¼ã«ããä½ã£ã¦updateãã¹ã slow query logã«è¦æ³¨æ å¤ãã®ã¨ã³ããªã§ã»ã¨ãã©ã®ãã£ã¼ã«ããåãå¤ãæã¤å ´åã¯ã¤ã³ããã¯ã¹ã®å¹æãå°ãã âè¤åã¤ã³ããã¯ã¹ã®å¹æã大ãã è¤åã¤ã³ããã¯ã¹ã¯æå®ã®é çªã大åãAã¨Bã¨ããæå®ã®å ´åãAåç¬ã§ãã¤ã³ããã¯ã¹ã®å¹æããããéã¯çã§ãªãã ã¤ã³ããã¯ã¹ã使ãããå ´é¢ã¯ ãã£ã¼ã«ãå¤ãå®æ°ã¨æ¯è¼ããã¨ã (where name = 'hogehoge') ãã£ã¼ã«ãå¤ã§JOINããã¨ã (where a.name = b.name) ãã£ã¼ã«ãå¤ã®ç¯å²ãæ±ããã¨ã (<,>,between) LIKEå¥ãæååããå§ã¾ãã¨ã (where name like 'hoge%') min(),
2007å¹´5æ31æ¥10:53 Tom-AdelsteinãBill-Lubanovicï¼2007å¹´5æ29æ¥ï¼ç«ï¼ï¼ ãã¡ã¤ã«ããã£ã¬ã¯ããªã®ããã¯ã¢ããã¯æ¯è¼çç°¡åã ãããã¼ã¿ãã¼ã¹ã®ããã¯ã¢ããã¨ãªãã¨ãããã¤ãç¹å¥ãªå·¥å¤«ãæ½ãå¿ è¦ããããããã§ã¯MySQLãåãä¸ãã¦ããããåãåçã¯PostgreSQLããã®ä»ã®ãªã¬ã¼ã·ã§ãã«ãã¼ã¿ãã¼ã¹ã«ããã¦ã¯ã¾ãã æ¬ç¨¿ã¯ãæè¿OâReillyããåºçãããæ¸ç±ã Linux System Administration ãã®æç²ã MySQLãµã¼ããä¼ã¿ãªã稼åããç¶ããå¿ è¦ããªããªãã以ä¸ã«ç¤ºããããªå§ç¸®ãªãã®ãªãã©ã¤ã³ããã¯ã¢ããææ³ãæã£ã¨ãæ©ãã MySQLãµã¼ããåæ¢ãããã # /etc/init.d/mysqld stop MySQLã®ãã¼ã¿ãã¡ã¤ã«ããã³ãã£ã¬ã¯ããªãã³ãã¼ãããä¾ãã°ãMySQLã®ãã¼ã¿ãã£ã¬ã¯ããª/var
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}