ãµãã¯ã¨ãªã¼ã«LIMITã使ã£ãå±¥æ´ç³»ãã¼ãã«ã®é«éå(MySQLã§ãããªã¢ã©ã¤ãºããã¥ã¼3 çªå¤ç·¨)
å±¥æ´ç³»ãã¼ãã«ã¯åºæ¬çã«ãã¼ã¸ã£ã¼ã§ãã¼ã¸åå²ãããã¨ãã»ã¨ãã©ã ã¨æãã¾ããååã®ã¨ã³ããªã¼ã§ãLIMITå¥ã使ã£ã¦30è¡ã ãåã£ã¦ãã¦ããä¾ã¨ãªã£ã¦ãã¾ããä»åã®åé¡ç¹ã¯ã巨大ãªãã¼ãã«Ã巨大ãªãã¼ãã«ã®JOINããããã¨ããããéãã®ã§ãã£ã¦ãäºãã©ã¡ããä¸æ¹ã®ãã¼ãã«ã®ãã¼ã¿ãçµã£ã¦ããã°ç¸å½æ©ããªãã¯ãã§ããããã§ã大æ¬ã¨ãªãcommentãã¼ãã«ã§å ã«LIMITãããã¦ãã¾ãã¾ãã
SELECT SQL_NO_CACHE comment_id , fu.user_name form_user_name , tu.user_name to_user_name , comment FROM (SELECT * FROM `comment` LIMIT 900000,30) cm,user fu,user tu WHERE fu.user_id=cm.from_user_id AND tu.user_id=cm.to_user_id
30 rows in set (3.48 sec)
æè¿ã¯サブクエリーにLIMITã使ããããã«ãªã£ããã§ãã...ãããã¨ãFROMå¥ã ã£ããLIMIT使ããã®ãã以ä¸ã¯MySQL 4.1.1ã®äººç¨ã«ãµãã¯ã¨ãªã¼ããã³ãã©ãªã¼ãã¼ãã«ã«å¤æ´ããä¾ã§ãã
- ãµãã¯ã¨ãªã¼ã«LIMITã使ããªãå ´åã«ãã³ãã©ãªã¼ãã¼ãã«ã使ç¨ããä¾
CREATE TEMPORARY TABLE t_comment ( PRIMARY KEY(comment_id) , INDEX(from_user_id) , INDEX(to_user_id) ) SELECT * FROM `comment` LIMIT 900000,30;
SELECT SQL_NO_CACHE comment_id , fu.user_name form_user_name , tu.user_name to_user_name , comment FROM `t_comment` cm,user fu,user tu WHERE fu.user_id=cm.from_user_id AND tu.user_id=cm.to_user_id