ä¸å®æéæ´æ°ããªãããåºåã表示ãã¦ãã¾ã
äºæ³ä»¥ä¸ã®å¹æãã§ãã®ã§è¨äºã«æ®ãã¾ãã DBã®æ å ±ãå ã«çµ±è¨ãè¡ãSQLã¨ããã°ã©ã ã®æ§è½æ¹åã§ãè¤åINDEXã試ãã¦ã¿ã¾ããã MySQLã¯ã4.2ã§ãã 対象ã¨ãªã£ãSQLã¯è¤æ°ããã¾ããããã®ãã¡ã»ã¨ãã©ã¯ï¼ã¤ã®ãã¼ãã«ãJOINãã¦ãã¾ããåå¾æ¡ä»¶ãå¤ããªããæ å ±ãåå¾ããæå¾ã«ç®çå¥ã«åç®ããã£ã¦ãããã¨ããã£ã¦ãã¾ããï¼ã¤ã®ãã¼ãã«ã®ãã¡ï¼ã¤ã¯ãã¼ã¿æ°200ä¸ãªã¼ãã¼ãï¼ã¤ã¯100ä¸ãªã¼ãã¼ã æåã¯ããããªç¶æ +----+-------------+-------+--------+----------------------------------------------+ | id | select_type | table | type | Extra | +----+-------------+-------+--------+-----------------
ã¤ã³ããã¯ã¹ãã¼ã¸ã¢ã¯ã»ã¹æ¹æ³ã§ã¯ãè¤æ°ã® range ã¹ãã£ã³ãå«ãè¡ãåå¾ããããã®çµæã 1 ã¤ã«ãã¼ã¸ããã¾ãã ãã®ã¢ã¯ã»ã¹æ¹æ³ã§ã¯ãåä¸ã®ãã¼ãã«ããã®ã¿ã¤ã³ããã¯ã¹ã¹ãã£ã³ããã¼ã¸ãããè¤æ°ã®ãã¼ãã«ã«ãããã¹ãã£ã³ã¯ãã¼ã¸ããã¾ããã ãã®ãã¼ã¸ã«ãã£ã¦ããã®åºç¤ã¨ãªãã¹ãã£ã³ã®åéåãå ±ééåãã¾ãã¯å ±ééåã®åéåãçæã§ãã¾ãã ã¤ã³ããã¯ã¹ãã¼ã¸ã使ç¨ã§ããã¯ã¨ãªã¼ã®ä¾: SELECT * FROM tbl_name WHERE key1 = 10 OR key2 = 20; SELECT * FROM tbl_name WHERE (key1 = 10 OR key2 = 20) AND non_key = 30; SELECT * FROM t1, t2 WHERE (t1.key1 IN (1,2) OR t1.key2 LIKE 'value%') AND
éããªãç æ°ãèªãPHP Internalsã®ã»ãã·ã§ã³ããéããããã£ã¡ã® è¬å¸«ã¯MySQL.comã®äººãè¬æ¼æ £ããã¦ãã¦ããã£ã¨ã¾ã¨ãã§ãããã§ãã·ã§ãã«ãª æããååä¸ãéããã®ãæãããã詳ãããã¬ã¼ã³è³æã¯å¾æ¥å ¬éããã ãããã DELETEã®ã³ã¹ãã¯ããªãé«ã èªã¿ã ãããããå¤ãå ´åã¯ç¡å¹åã示ããã£ã¼ã«ããä½ãUPDATEãã¹ãã indexæ´æ°ã®ã³ã¹ãã馬鹿ã«ãªããªãSHOW STATUSã®è¡¨ç¤ºçµæã®è§£ææ¹æ³ èµ·åãã¨ã«åæåãå ¨ãã¼ã¿ãã¼ã¹ã«å ±érnd 㨠rnd_next ã®å²åKey_reads : Key_read_requests ããã£ã¹ã¯ããèªã¾ããåæ°ï¼ç·åæ° ãã®å²åã1:100ããæªããªã£ããè¦æ³¨æKey_write_requests:Key_writes ç·æ¸ãè¾¼ã¿è¦æ±åæ°ï¼ãã£ã¹ã¯ã«æ¸ã込㾠ããåæ° ãã£ãã·ã¥ã®å¹æãªã©Max_used_con
ï¼¼ééäºå®ã®ãµã¤ãã売ããããï¼ï¼ ã¢ã¯ã»ã¹ããªããµã¤ããã³ã³ãã³ã価å¤ã§å£²ããå ´åã⦠ãã¡ã¤ã³ã®æå¹æéãæ´æ°ãã¦ãµã¤ã売å´ã«ãã©ã¤ãã¦ã¿ã¾ããã
ã¨ããããã§ãåã³è² è·ãä¸ããæ¹æ³ã模索ãããæ¦ãã®è¨é²ã 1.MySQLã®è¨å®ãå¤æ´ãã¦é«éå 2.Zend Optimizer 3ã®å°å ¥ 3.ionCube PHP Acceleratorã®å°å ¥ 4.ãã³ãã¬ã¼ãã®è¦ç´ãã§ã¯ã¨ãªã¼ãæ¸ãã 5.robots.txtã§ã¯ãã¼ã«ããééãå¶å¾¡ãã 6.MySQLã®è¨å®ãè² è·ãä½ãããè¨å®ã«å¤æ´ 7.ãã£ãã·ã¥ãæå¹åãã åå解説ãããGIGAZINEã®LoadAverageãã27ãããã2ãã¸ä¸ããæ¹æ³ãããç´3é±éå¾ã6æ20æ¥ï¼ç«ï¼ã®å¤ãæ°ãã¤ãã¨è² è·ã®15åå¹³åã¯ã25ããã³ã³ã¹ã¿ã³ãã«åãåºãããã«ãªããããã«è¨ªåè ã¯æ¥å¢ãã¤ãã«6æ28æ¥ï¼æ°´ï¼12æ45åãè² è·å¯¾çã®å¹æãã»ã¨ãã©åºãªãã¾ã¾ãLoadAverage15åå¹³åã¯ã86ãã«â¦ã ä½ã対çãæ ¹æ¬çã«ééã£ã¦ããã®ã ãããï¼ããã¨ããããGIGAZINEãµã¼ãã®ãã¼ã
以åãMySQLãé«éåãã10ã®æ¹æ³ã¨ããæ稿ã§ãEXPLAINã®è¦æ¹ã«ã¤ãã¦ã¯ããã解説ãããã¨æããã¨æ¸ãã¦ãã¾ã£ãã®ã§ãä»æ¥ã¯ãã®å ¬ç´ï¼ãæãããã¨æãã MySQLã®ãã¥ã¼ãã³ã°ã§æã大åãªã®ã¯ãã¯ã¨ãªã¨ã¹ãã¼ãã®æé©åã§ãããã¹ãã¼ãã®è¨è¨ã¯ä¸åº¦æ±ºãã¦ãã¾ãã¨ãã®ãã¼ãã«ãå©ç¨ããå ¨ã¦ã®ã¯ã¨ãªã«å½±é¿ãã¦ãã¾ããããªããªãå¤æ´ãããã¨ã¯åºæ¥ãªãããã¯ã¨ãªã¯ãã®ã¯ã¨ãªã ããæ¸ãç´ãã°è¯ãã®ã§å¤æ´ã®æ·å± ã¯ä½ããããã¦é ãã¯ã¨ãªããªãããã¨ã¯ãæ§è½ãå¤§å¹ ã«åä¸ãããããã®æãæå¹ãªæ段ã§ãããå¾ã£ã¦ãã¢ããªã±ã¼ã·ã§ã³ã®æ§è½ãåä¸ãããããªããã¾ãæåã«ã¯ã¨ãªã®ãã¥ã¼ãã³ã°ãæ¤è¨ããã¹ããªã®ã§ããã æé©åããã¹ãã¯ã¨ãªã¯ã¹ãã¼ã¯ã¨ãªãã°ãã¯ã¨ãªã¢ãã©ã¤ã¶ã§è¦ä»ããããããã§ã¯ãã®ãããªã¯ã¨ãªãè¦ã¤ãã£ãå ´åã«ã¯ã©ã®ããã«æé©åããã°ããã®ãï¼ãã®ããã«ã¯ã¾ãç¾å¨ã©ã®ããã«ã¯ã¨ãªãå®è¡ã
IO::Fileã¨æ®éã«ãã¡ã¤ã«ãã³ãã«ä½¿ãã®ã¨ã©ã£ã¡ãéãã®ããªãã¨æãããã³ããã¼ã¯ã¹ã¯ãªãããæ¸ãã¦è©¦ãã¦ã¿ã¾ããã Perlã®ãã¼ã¸ã§ã³ã¯5.8.8ã§ãã #!/usr/bin/perl use strict; use warnings; use IO::File; use Benchmark; my $file = "hoge.txt"; timethese ( 100000, { 'IO::File', '&with_IO_File;', 'FileHandle', '&without_IO_File;', } ); sub with_IO_File { my $fh = IO::File->new($file); push my @lines, $_ while <$fh>; $fh->close; \@lines; } sub without_IO_File { open
ä»æ¥ã¯ä»äºç´ãã ã£ãã®ã§ãä¸å¹´ã®ç· ããããã¨ãã¦MySQLã«ãããã½ã¼ãã®è©±ã§ããããã¨æãã ã¤ã³ããã¯ã¹ãå©ç¨ããªãã¯ã¨ãªã§æãããè¦ããããã®ã®ã²ã¨ã¤ã¯ãORDER BYãç¨ããã½ã¼ãå¦çã ããããããã½ã¼ãå¦çã«ããã¦ã¤ã³ããã¯ã¹ãç¨ãããã¨ãåºæ¥ãã°ãMySQLã¯çµæãæ½åºãã¦ããçµæè¡ãã½ã¼ãããã®ã§ã¯ãªããã¤ã³ããã¯ã¹é ã«è¡ãåãåºãã°è¯ãã®ã§é«éã«ã½ã¼ãå¦çãããã¨ãå¯è½ã«ãªããç¹ã«ãLIMITå¥ãWHEREå¥ãç¨ãã¦è¡ã®çµãè¾¼ã¿ãè¡ãå ´åã¯å¹æã絶大ã§ãããããããã²ã¨ãã³ã¤ã³ããã¯ã¹ãå©ç¨ã§ããªãç¶æ³ã«ç´é¢ããã¨ããã¡ã¾ã¡ãã¼ãã«ã¹ãã£ã³ãçºçãã¦æ§è½ãå£åãã¦ãã¾ãã ä¾ãã°ã100ä¸è¡ã®ã¬ã³ã¼ããæ ¼ç´ããt1ã¨ãããã¼ãã«ãããã¨ããããã®ãã¼ãã«ã«å¯¾ãã¦ä»¥ä¸ã®ãããªã¯ã¨ãªãå®è¡ããå ´åãèãããã mysql> SELECT col1, col2 ... colx
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_
éç´æ¼ç®ãè¡ãã±ã¼ã¹ã§ã¯ãè¡ã®ãµã¤ãºãå°ããä¿ã¤ãã¨ã¯ã¨ã¦ãéè¦ãã¢ã¯ã»ã¹é »åº¦ãä½ãã³ã©ã ã¯å¥ãã¼ãã«ã«è¿½ãåºãã¨ãããã»ãããããããã ä¸æ¹ãéç´æ¼ç®ãè¡ããªãã±ã¼ã¹ (åä¸è¡ã® insert, update çãå«ã) ã®å ´åã¯ã(ã¯ã©ã¤ã¢ã³ãã¨ã®éä¿¡ã®ããã®) ã·ã¹ãã ã³ã¼ã«ããªã¼ãã¼ãããã«ãªãã®ã§ãå°ããªãã¼ãã«ã«ããããã¢ã¯ã»ã¹ãããããããé·ãè¡ãæã¤ãã¼ãã«ã«ï¼åã¢ã¯ã»ã¹ããã»ããè¯ãã ãã¨ãã°æå ã®ç°å¢ã§ã® insert on duplicate key update ã®é度ã¯ã è¡ã®ãµã¤ãº å¿ è¦æé 0KB 1 3KB 4 6KB 7 9KB 13 12KB 13 ã¨ããããªæã (ç°å¢ãã¯ã¨ãªã«ããå¤ããã®ã§èªåã§æ¸¬å®ãã¦ãã9KB ã®é度ä½ä¸ã¯ãã¼ã¸ãµã¤ãºã®1/2ãè¶ ããããããª)ãã¤ã¾ããè¡ã®ãµã¤ãºã1KBç¨åº¦ã ã¨ãéä¿¡ã®ãªã¼ãã¼ãããã大ãããããã¾ãåé¡ã«
This domain may be for sale!
é常ãMySQLã§ã¯ãselectã³ãã³ããå®è¡ããå ´åã1ã¬ã³ã¼ãç®ããæçµã¬ã³ã¼ãã¾ã§ãã·ã¼ã±ã³ã·ã£ã«ã«æ¤ç´¢ãè¡ã£ã¦ããã¾ãã ããããªãããã¬ã³ã¼ãæ°ã大éã«ãªã£ã¦ããã¨ãæ¤ç´¢é度ã®åé¡ãçãã¾ãã ããã§ãããé«éãªæ¤ç´¢ãè¡ãããã«ãã¤ã³ããã¯ã¹ãä½æããã®ãä¸è¬çã§ãã ã¤ã³ããã¯ã¹ãä½æãããã¨ã«ãã£ã¦ãæ¤ç´¢é度ã¯åçã«æ¹åããã¾ãã ä½ããMySQLã§ã¯ã1,000件以ä¸ã§ããã°ã·ã¼ã±ã³ã·ã£ã«ã«æ¤ç´¢ããæ¹ãéãã¨ããã¦ãã¾ãã ãã¦ãã¤ã³ããã¯ã¹ã¨ã¯ã©ã®ãããªãã®ã§ãããã¨ããã¨ãç´æçã«ã¯ãå³æ¸ã®å·»æ«ã«ä»ããã¦ããç´¢å¼ï¼ã¤ã³ããã¯ã¹ï¼ã¨åãã§ãã ç´¢å¼èªã¯ã¢ã¤ã¦ã¨ãªé ããããã¯ãã¢ã«ãã¡ãããé ã«ä¸¦ã¹ããã¦ãã¦ãåã ã®ç´¢å¼èªã«ã¯ããã®ç´¢å¼èªãç»å ´ãããã¼ã¸æ°ï¼ä½ç½®æ å ±ï¼ã示ããã¦ãã¾ãã èªè ã¯ãã®ä½ç½®æ å ±ãé ¼ãã«ããã¼ã¸ãæ²ã£ã¦ãç®çã®ãã¼ã¯ã¼ãã®ããé¨åãèª
MySQL ã®ãã¥ã¼ãã³ã°é¢é£ã®ããã¥ã¡ã³ããèªãã§ããã¨ãORDER BY ãé¿ãããã¨æ¸ãã¦ãããã©ãã§ããªã (or ããããªã) å ´åãããããã§ãããããæã¯ã½ã¼ãç¨ã®è¡¨ã¨è¡¨ç¤ºç¨ã®è¡¨ãåå²ãèªå·±çµåãããã¨ã§ãé«éåã§ãããã¨ãããã¾ããé©å½ãªä¾ã§ããã mysql> SHOW CREATE TABLE testt\G *************************** 1. row *************************** Table: testt Create Table: CREATE TABLE `testt` ( `id` int(10) unsigned NOT NULL AUTO_INCREMENT, `priority` int(10) unsigned NOT NULL, `data` varchar(255) NOT NULL, PRIMAR
ããããã¤ãã æ è¡ã¨ãã¤ã¯ã¨ãã©ã¤ãã¨æçã¨å®å®ã好ãã Ubie Discoveryã®ããã°ã©ãã MySQLã³ã³ãã¡ã¬ã³ã¹2008ã«åå ãã¦ãã¾ãããåæé訳ã¨ãããã®ãã¯ããã¦çµé¨ãããã©ããã£ããç解ãã«ãããã®ã§ããããµã¤ãã«è±èªãèãã¦ããã»ããããã£ããã(è±èªãããç解ã§ããªããã©)ãã¨ããã©ãããé ãæ··ä¹±ãã¦ãã¾ã£ã¦ããããããªãã£ãã¨ãããããã¾ããã ä»äºããã£ãã®ã§2æ¥ç®ã ãã®åå ã§ããã ã¼ããèãã¦ã¼ããªãã«ç解ããå 容ã ã£ãã(ã¾ãã¯ããç解ã§ãã¦ããªãå 容ã ã£ãã)ããã®ã§ãäºå®ã¨ã¯ç°ãªãã¨ãããããããããã¾ããã 1.MySQL Performance Tuning 1 ããã«ããã¯ã¨ãªãç®æãããããã¨ã大å ã¹ãã¼ã¯ã¨ãªãã° ã»åºæ¬ ã»åå詳細ã§ã¯ãªã ã»ã©ããéå¹çãªã®ãã¾ã§ã¯ããããªã ã»æå»(æé帯ã«ããç°å¢ã®å½±é¿ã¯?)ãã¦ã¼ã¶(ã©ã®ã¢ããª?
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}