# SQLãã¥ã¼ãã³ã° çè«ã¨æ¹åã®å®ä¾ - 2019-11-15 éå¬ã®PostgreSQL Conference Japan 2019 ã®çºè¡¨ã¹ã©ã¤ãã§ã
ãã®å³ãã¨ã¦ããããæãã£ãã åºå ¸: Visual Representation of SQL Joins - CodeProject stackoverflow.com
MySQL Casual Advent Calendar 2016 - Qiitaã®6æ¥ç®ã®è¨äºã§ãã AdventCalendarèªä½ååå ã§ããããããã¦ãããæãè¡ãã§2æ¥é£ç¶ã ã³ã¬ç¨ã®ããããªã¨ããã³ã¹åãããããªç°å¢è¦ãã¦ããªãã£ãã®ã§ãæ®æ®µããèã£ã½ãã§ãããCasualãªæãã§å¤±ç¤¼ãã¾ãã 大ããªãã¼ãã«ãç¹°ãè¿ãSELECTãã¦ãããæåãå¤ãã£ããã§ããã ãããã¡ã«è¼ã£ã¦ãããªãè¼ã£ã¦ããã§æ©ãã ããããè¼ã£ã¦ãããªãæåã¬ãããªé ãã¦ã次ããã°ã¤ã£ã¨éããªãã ããã¨æã£ã¦ãããã§ããã ãããã¡ã«è¼ããããªããªããä½åãã£ã¦ãé ãã ããã¨æã£ã¦ãããã§ããã ã§ãã¡ããã¨è¨æ¸¬çãªãã¨ããã£ã¦ãé¢ä¿ã§ãåãSQLãä½åº¦ãå©ãã¦å¹³åãä¸å¤®ãè¦ããã¨æã£ã¦ãããã§ãã ããããã 45.71ç§ã44.90ç§ã24.44ç§ã13.32ç§ã13.12ç§ã»ã»ã» ã¨ã段éçã«å¿ç
ISUCON5ã®åºé¡æ å½ã®ä¸äººãkamipoã§ãã ä»åã¯ISUCON5ã®äºé¸åé¡ãã©ãããåé¡ã ã£ãã®ããæ¯ãè¿ã£ã¦ã¿ã¾ãããï¼ äºé¸åºé¡ãISUxiãä»åã®äºé¸ã®åºé¡ã«ãããã¡ã¤ã³ãããã¯ã¯ãN+1åé¡ãã§ããããã®åé¡ã«ãã¾ã対å¦ã§ãããã©ãããçµæã«å¤§ããå½±é¿ããã¨æãã¾ããã¾ããISUxiã§ã¯N+1åé¡å«ãå¶éæéå ã«ã¯å¯¾å¦ããããªããããå¤ãã®åé¡ãã/ããã¼ã¸ã«è©°ãè¾¼ã¾ãã¦ããã®ã§ããããã®åé¡ã¸ã®åªå é ä½ä»ããçå®ã«å¯¾å¦ã§ããããéè¦ã§ãããã¨ããããã§ãã/ããã¼ã¸ã®ããã«ããã¯ã«ã¤ãã¦è§£èª¬ãããã¨ã§æ¬äºé¸ã®æ¯ãè¿ãã¨ãããã¨æãã¾ãã N+1ã/ããã¼ã¸ã§ã¯is_friend?ã¨get_userã®å¤§éã®å¼ã³åºããããã¾ããããããã¯user_idã«ç´ä»ããã¼ã¿ãªã®ã§SQLã§JOINãããã¨ã§å¼ã³åºããç¡ãããã¨ãã§ãã¾ãããããã¯ãusersãã¼ãã«ã®å 容ãå¤æ´ããæ©è½
åæ¸ã - ã¤ã³ããã¯ã¹ã®ä½æã¯ãªãéçºè ã®ã¿ã¹ã¯ãªã®ã ã¤ã³ããã¯ã¹ã® å é¨æ§é - ã¤ã³ããã¯ã¹ã¯ä½ã«ä¼¼ã¦ããã ã¤ã³ããã¯ã¹ ãªã¼ããã¼ã - äºéé£çµãªã¹ã æ¤ç´¢ ããªã¼(Bããªã¼) - ãã©ã³ã¹æ¨ é ãã¤ã³ããã¯ã¹ ãã¼ãI - ã¤ã³ããã¯ã¹ãé ããã2ã¤ã®åå where å¥ - æ¤ç´¢ã®ããã©ã¼ãã³ã¹ãæ¹åããããã«ã¤ã³ããã¯ã¹ãä½æ ç価 æ¼ç®å - ä¸è´ãããã¼ã®æ¤ç´¢ ãã©ã¤ããªãã¼ - ã¤ã³ããã¯ã¹ã®ä½¿ãæ¹ãç¢ºèª è¤åã¤ã³ããã¯ã¹ - è¤æ°åã«å¯¾ããã¤ã³ããã¯ã¹ é ãã¤ã³ããã¯ã¹ ãã¼ãII - åã®åé¡ç¹ãåã³ é¢æ° - whereå¥ã® ä¸ã§ã®é¢æ° 大æåã»å°æåãåºå¥ãã æ¤ç´¢ - UPPER㨠LOWER ã¦ã¼ã¶å®ç¾© é¢æ° - é¢æ°ã¤ã³ããã¯ã¹ã®å¶é ã¤ã³ããã¯ã¹ã®ä½ãéã - åé·æ§ã®æé¤æ³ ãã©ã¡ã¼ã¿å ã¯ã¨ãª - ã»ãã¥ãªãã£ã¨ããã©ã¼ãã³ã¹ã®ããã« ç¯å² æ¤
SQLã®ããã°ã©ãã³ã°ã¯å¥¥ãæ·±ããç¹ã«ããã©ã¼ãã³ã¹ã®è¦³ç¹ãããããè¨ããã ããã ã¿ãªãããæ¿ç¥ã®éããåãçµæãåºãããã°ã©ã ã§ããSQLã®æ¸ãæ¹æ¬¡ç¬¬ã§å¦çæéã«ä½åãã®å·®ãçãå¾ããå¹çã®æªãSQLãæ¸ãã¦ãã¾ãåå ã¯ãå¤ãã®å ´åããªã¬ã¼ã·ã§ãã«ãã¼ã¿ãã¼ã¹ã®å é¨åä½ãã¢ããªã±ã¼ã·ã§ã³ã«é¢ããç解ä¸è¶³ã§ããã両è ãããç¥ã£ãä¸ã§æé©ãªSQLãæ¸ããããã«ãªããã¨ã¯ãã·ã¹ãã ã¨ã³ã¸ãã¢ã¨ãã¦ã®éè¦ãªã¹ãã«ã®ä¸ã¤ã§ããã ç¹éãåºç¤ããç解ãããã¼ã¿ãã¼ã¹ã®ããã¿ãã§ã¯ããªã¬ã¼ã·ã§ãã«ãã¼ã¿ãã¼ã¹ã®å é¨åä½ã«ã¤ãã¦ãåºæ¬çãªé¨åãåããããã解説ãã¦ãããSQLããã°ã©ãã³ã°ã«å½¹ç«ã¤ãã¨ã¯ãã¡ãããSQLãã¥ã¼ãã³ã°ããã¼ã¿ãã¼ã¹è¨è¨ã®ããã®åºç¤ç¥èã¨ãã¦ãä¸å¯æ¬ ã ã ã¤ã³ãããã¯ã·ã§ã³ ãã©ãã¯ããã¯ã¹ã®ã¾ã¾ã§ããã®ï¼ Part 1ï¼SQLæã¯ã©ã®ããã«å®è¡ãããã®ã SQLå®è¡ã¾ã§ã®
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}