https://kaigionrails.org/2024/talks/osyoyu/
ã¯ããã« Postgres ã«ã¯ JSON/JSONB ã¨ãããã¼ã¿åãããã¾ããï¼JSONB ã¯ãã¼ã¿ããã¤ããªå½¢å¼ã§æ ¼ç´ããããã¤ã³ãµã¼ãæã«å¤æã®ãªã¼ãã¼ãããããããã®ã®ï¼ãã®å¾ã®å¦çãé常ã«é«éã§ããä¸ã«ï¼ã¤ã³ããã¯ã¹ãè²¼ããã¨ãã§ããããï¼å®ç¨ä¸ã¯ JSONB ã使ãã®ãä¸è¬çã§ãï¼ ä¸æ¹ã§ï¼ãããã RDB ã®ãããªã¹ãã¼ãã®å³æ ¼ãªåä»ãããã¦ããã·ã¹ãã ã§åæ§é åãã¼ã¿ã§ãã JSON ãæ±ããã¨èªä½ãã¢ã³ããã¿ã¼ã³ã§ããã¨ããææãããã¾ãï¼ ããããªããï¼é©åã«è¨è¨ï¼éç¨ãããã¨ã§å³æ ¼ãª RDB ã§æè»ãªãã¼ã¿ãæ±ããã¨ãã§ãï¼ã¢ããªã±ã¼ã·ã§ã³ã®è¡¨ç¾ã®å¹ ãåºãããã¨ãã§ãã¾ãï¼ æ¬è¨äºã§ã¯ï¼JSONB ãå¯è½ãªéãå®å ¨ã«æ±ãããã®å®è·µçãªå·¥å¤«ãç´¹ä»ãã¾ãï¼ JSON Schema ã使ã£ãããªãã¼ã·ã§ã³ã Check Constraint ã«ãã Postgres ã§ã¯
æ¬ã»ãã·ã§ã³ã§ã¯PC/ã¹ãã¼ããã©ã³åãã²ã¼ã ãã¬ã¼ã«ãã¬ã³ã(ä»®)ãã®ãã¼ã¿ãã¼ã¹ã®è² åµã¨ãã®è§£æ¶ã®éã®ãããç´¹ä»ãã¾ãã å½ã²ã¼ã ã§ã¯ãã¼ã¿ãã¼ã¹ã«MySQLãæ¡ç¨ãã¦ãããé·å¹´ã®éç¨ãç¶ãã¦ããä¸ã§ä¸è¨ã®ãããªèª²é¡ãçºçãã¦ãã¾ããã ãçªçºçãªã¦ã¼ã¶ã¼å¢å ã§æ´æ°è² è·ã«èããããªãã ããã¼â¦
ä»åã®è¨äºã¯ãããã©ã¼ãã³ã¹ãã¥ã¼ãã³ã°ã®è¦³ç¹ã¨ä»çµã¿ãç解ãããã¨ã«ä¸»ç¼ãç½®ãã¦ãã¾ããå ·ä½çãªå¯¾å¦æ¹æ³ã«ã¤ãã¦ã¯ã·ã¹ãã ã«ãã£ã¦ç°ãªããããããã¥ã¢ã«ã®ç¢ºèªããå種ãã¥ã¼ãã³ã°ãµã¼ãã¹ã®ãå©ç¨ããæ¤è¨ãã ããããªãããã®è¨äºã§å¯¾è±¡ã«ãã¦ããPostgreSQLã®ãã¼ã¸ã§ã³ã¯9.5以éã§ãã æ¬è¨äºã®æ§æ æ¬è¨äºãããã©ã¼ãã³ã¹ãã¥ã¼ãã³ã°9ã¤ã®æãã¯ä»¥ä¸4ã¤ã®è¨äºããæ§æããã¦ãã¾ããä»ã®è¨äºãä½µãã¦ã覧ãã ããã ããã©ã¼ãã³ã¹ãã¥ã¼ãã³ã°9ã¤ã®æ ï½ã¯ããã«ï½ ããã©ã¼ãã³ã¹ãã¥ã¼ãã³ã°9ã¤ã®æ ï½ãæ¸ããã«ã¤ãã¦ï½ï¼æ¬è¨äºï¼ ããã©ã¼ãã³ã¹ãã¥ã¼ãã³ã°9ã¤ã®æ ï½ãæ¢ããã«ã¤ãã¦ï½ ããã©ã¼ãã³ã¹ãã¥ã¼ãã³ã°9ã¤ã®æ ï½ãåºç¤ãã«ã¤ãã¦ï½ 1. ããã©ã¼ãã³ã¹ãã¥ã¼ãã³ã°ã®ãæ¸ããã¨ã¯ ä¸è¬çã«ãã¼ã¿ãã¼ã¹ã¯ã大éãã¼ã¿ãæ±ãã大éã®åãåãããæ´æ°ãé«éã«å¦çããããã«é害çºç
è¿å¹´ãECãµã¤ãããã®å人æ å ±åã³ã¯ã¬ã¸ããã«ã¼ãæ å ±ã®æµåºäºä»¶ãå¤æ°çºçãã¦ããã被害ã®å¤§åãä¸å°ä¼æ¥ã®èªç¤¾æ§ç¯ãµã¤ããå ãã¦ãã¾ããä¸å°ä¼æ¥ã®èªç¤¾æ§ç¯ãµã¤ãã«ããã¦ã¯ãã»ãã¥ãªãã£å¯¾çã®å¿ è¦æ§ãååã«ç解ããã¦ããªããããé©åãªã»ãã¥ãªãã£å¯¾çãè¡ããã被害ãæãã¦ããç¶æ³ã§ãã ECãµã¤ãã®ã»ãã¥ãªãã£å¯¾çãå¼·åãããããIPAã§ã¯ECãµã¤ãæ§ç¯ã»éç¨æã®ã»ãã¥ãªãã£å¯¾çãã¾ã¨ãããECãµã¤ãæ§ç¯ã»éç¨ã»ãã¥ãªãã£ã¬ã¤ãã©ã¤ã³ããä½æããæ¬æ¥(2023å¹´3æ16æ¥)ãå ¬éãã¾ããã ã¬ã¤ãã©ã¤ã³ã®å 容 ECãµã¤ãã§ã²ã¨ãã³äºæ åã³è¢«å®³ãçºçããã¦ãã¾ãã¨ãECãµã¤ãã®é·æéã®ééã«ä¼´ã売ä¸é«ã®å¤§å¹ ãªæ¸å°ããåå 調æ»ã被害ã®è£åçã®äºæ 対å¿è²»ç¨ãå«ãç大ãªçµæ¸çæ失ãçºçãã¾ãã æ¬ã¬ã¤ãã©ã¤ã³ã¯ãECãµã¤ããæ§ç¯ãéå¶ããã¦ããä¸å°ä¼æ¥ã®çæ§ã«ãECãµã¤ãã®ã»ãã¥ãªãã£å¯¾çãå®æ½ãã
ããã«ã¡ã¯ãã¤ã³ãã©ã¨ã³ã¸ãã¢ã® gumamon ã§ãï¼ è¿å¹´ãKubernetesçã®ç»å ´ã«ãããã¢ããªã±ã¼ã·ã§ã³ã®ã¹ã±ã¼ã«ã¢ã¦ãã¯ã¨ã¦ãç°¡åã«ãªãã¾ããã対ãã¦ããã¼ã¿ãã¼ã¹(DB)ã®ã¹ã±ã¼ã«ã¢ã¦ãã¯ä¾ç¶ã¨ãã¦å°é£ã§ãã ãRDBMSãâ ãã¼ã¿ã®ä¸è²«æ§ã¯ä¿ã¦ãããã¹ã±ã¼ã«ã¢ã¦ããé£ãã ãNoSQLãâ ãã¼ã¿ã®ä¸è²«æ§ãä¿ã¦ãªãããã¹ã±ã¼ã«ã¢ã¦ãã容æ DBã®ã¹ã±ã¼ã«ã¢ã¦ããèããã¨ãã®ï¼æã«è¡ãã¤ããã¨ããã®ãä»ã¾ã§ã®å¸¸èã ã£ããã¨æãã¾ããã ãã©ã£ã¡ãï¼ããåºæ¥ã¦ãã¾ã第ï¼ã®é¸æè¢ãç»å ´ãã¾ããã ãã¼ã¿ã®ä¸è²«æ§ãä¿ã¦ãä¸ã¤ã¹ã±ã¼ã«ã¢ã¦ã容æãªãNewSQLãï¼ æè¿ãNewSQLã®ä¸ã¤ã§ãã yugabyteDB ã®æ¤è¨¼ãããæ©ä¼ãããã¾ããã®ã§ãã¢ã¼ããã¯ãã£ã¨æ¤è¨¼çµæãç´¹ä»ãã¾ãã ç®æ¬¡ ç®æ¬¡ ããããããã yugabyteDBï¼ yugabyteDBã®ã¢ã¼ããã¯ãã£
PlanetScaleã¨ãããµã¼ãã¬ã¹DBãåãå¢ãã®ãããµã¼ãã¹ã¨èãã¦ãå ¬å¼ã«ã¯ã¤ãã¯ã¹ã¿ã¼ãããã£ãã®ã§ãã£ã¦ã¿ã¾ããã ç°å¢ PC: MacBook Pro (Intel Core 2016) OS: macOS Montery12.2.1 ã§ã¯æ¦è¦ãã確èªãã¦ããã¾ãã ãµã¼ãã¼ã¬ã¹DBã¨ã¯ ãµã¼ãããªããã®ã§ã¯ãªãããµã¼ã管çãæ¤è¨ãä¸è¦ AWS Lambda(NoSQL)ãªã© PlanetScaleã¨ã¯ PlanetScale年表 2010å¹´é YouTubeãæ¥æ¿ã«æé·ãããã¼ã¿ãã¼ã¹ãççºãããã«ãªã£ã¦ããã®ã§ãSuguæ°ã¨ããä¸äººã®YouTubeã®ã¨ã³ã¸ãã¢ããªã¼ãã³ã½ã¼ã¹ããã¸ã§ã¯ããVitess.ioãï¼ã´ã£ãã¹ï¼ãç«ã¡ä¸ãã 2016å¹´é MySQLã§ãã¤ããªãããã³ã«ãæ±ããããã«ãããã¨ã§ãVitessã¯YouTube以å¤ã®ä¼æ¥ã«ã¨ã£ã¦ãé åçãªã·ã¹ãã ã«ãªã
ãã®è¨äºã¯ DeNA 20 æ°å Advent Calendar 2020 19æ¥ç®ã®è¨äºã§ãã ã¯ããã« MySQLãPostgreSQLã«ä»£è¡¨ãããRDBMSã§ã¯ãã©ã³ã¶ã¯ã·ã§ã³ã¨å¼ã°ããä»çµã¿ãæä¾ããã¦ãã¾ããå¤ãã®Webã¢ããªã±ã¼ã·ã§ã³ã¨ã³ã¸ãã¢ã¯ãã®ãã©ã³ã¶ã¯ã·ã§ã³ãé§ä½¿ãã¦DBã¨ããã¨ãããããã¸ãã¯ãçµã¿ç«ã¦ããã¨ã«ãªãã¾ãã ãããä¸æ´åãèµ·ãããããªãå¦çãããããã¨ãã£ã¦éé²ã«ãã©ã³ã¶ã¯ã·ã§ã³ãå¼µã£ããããã©ã³ã¶ã¯ã·ã§ã³ãå¼µããã¦ããããã¨å®å¿ãã¦ã¢ããªã±ã¼ã·ã§ã³å´ã§éé²ã«ãã¸ãã¯ãçµã¿ç«ã¦ã¦ãã¾ãã¨æãã¬ãã°ãçããã¨ã«ãªã£ã¦ãã¾ãã¾ãã ãã®ã¨ã³ããªã§ã¯ãããã©ã³ã¶ã¯ã·ã§ã³ãå¼µã£ã¦ããã°å¤§ä¸å¤«ãã¨ããèãæ¹ã¯å±éºãªå ´åãããã¨ãããã¨ãããããã¡ãªå®è£ ä¾ã交ãã¦ç´¹ä»ãã¦ããã¾ãã 並åã«å¦çããããã©ã³ã¶ã¯ã·ã§ã³ ããããããã©ã³ã¶ã¯ã·ã§ã³ã¯å ¨ã¦ç´åã«å¦çãããã
IDçæã«ã¤ãã¦èããããã¨ãå¤ãã®ã§ãç¬èªã®è¦³ç¹ã§ã¾ã¨ãã¦ã¿ã¾ããã¿ã¤ãã«ã¯é©å½ã§ãâ¦ã DBã¯MySQL(InnoDB)ãæ³å®ãã¦ãã¾ãããããããã IDçæãç¥ããããªã IDçæã«é¢ãã¦ã¯ä»¥ä¸ã®è¨äºãããã¾ã¨ã¾ã£ã¦ããã®ã§åèã«ãã¦ã¿ã¦ãã ãããå¤å½¢å¼ãªã©è©³ããæ¸ããã¦ãã¾ãã IDçæå¤§å ¨ Facebook, Twitter, Instagramçãã©ããã£ã¦IDãçæãã¦ããã®ã ã¾ã¨ã IDçææ¹æ³ 以ä¸ã®IDçææ¹æ³ã¯ããæ軽ã«æ¡ç¨ãããããã®é ã§åæãã¾ãã DBæ¡çª/é£çªå AUTO_INCREMENT DBã®AUTO_INCREMENTã§æ¡çªããæ¹æ³ã Pros æ°å¤åã§æ±ãã æ®éã¯64ãããã®æ´æ°åãæ¡ç¨ãããã¨ãå¤ã å調å¢å ããé£çªã§ãã®ã§ãã½ã¼ãå¯è½ã§ãã¤ã¤ã³ããã¯ã¹ã®ç©ºéå¹çããã å調å¢å ããã®ã§ããã£ãã·ãã£ãäºæ¸¬ãããã 64ãããããã°ãã¾ãæ°ã«
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}