Kaigi on Rails 2024ãä½ã£ã¦ç解ãã RDBMSã®ããã¿ãã®çºè¡¨ã¹ã©ã¤ãã #kaigionrails https://kaigionrails.org/2024/talks/ydah/
Skip to the content. èªä½RDBMSãããã! ãã®ãµã¤ãã®ç®ç RDBMSï¼ãããããªã¬ã¼ã·ã§ãã«ãã¼ã¿ãã¼ã¹ï¼ã¨ãããã®ã¯ããã°ã©ãã³ã°è¨èªã®å¦çç³»ããOSãªã©ã¨åæ§ã«ãä¸ã®ä¸ã§åºã使ããã¦ããã½ããã¦ã§ã¢ã§ããã«ãé¢ããããããèªä½ãã¦ã¿ããã¨æãã¨æ¥æ¬èªã§è¨è¿°ããããµã¤ããæ¸ç±ã§ãå¿ è¦ãªæ å ±ã»æ å ±æºãã¾ã¨ã¾ã£ããã®ããªããã¨ã«æ°ã¥ãã¾ãã ããã§ãå©ãå°ã¨ãã¦ãæ¬ãµã¤ã管ç人ããã³æ°åã®ã³ããã¿ã§éçºãã¦ããèªä½RDBMSã§ãã SamehadaDB ãè»éã«ä¹ãã¾ã§ã®çµé¨ããã¼ã¹ã«ãèªä½RDBMSããããã®éçãããç¨åº¦æ´çãã¦æ¸ãè¨ãã¦ã¿ã¾ãã åã ã®æ å ±ã»æ å ±æºã¯ããããããå¤ããè±èªã§è¨è¿°ããã¦ãã¾ããããã®ç¹ã¯ã容赦ä¸ãã ãªããæ¬ãµã¤ãã¯æè¡çãªè§£èª¬ãæä¾ããã®ã§ã¯ãªããé©åã¨æãããæ å ±ã»æ å ±æºããã¤ã³ããããããªãµã¤ãã¨ãªããã¨ãæ³å®ãã¦ãã¾ã
ãã®è¨äºã¯ DeNA 20 æ°å Advent Calendar 2020 19æ¥ç®ã®è¨äºã§ãã ã¯ããã« MySQLãPostgreSQLã«ä»£è¡¨ãããRDBMSã§ã¯ãã©ã³ã¶ã¯ã·ã§ã³ã¨å¼ã°ããä»çµã¿ãæä¾ããã¦ãã¾ããå¤ãã®Webã¢ããªã±ã¼ã·ã§ã³ã¨ã³ã¸ãã¢ã¯ãã®ãã©ã³ã¶ã¯ã·ã§ã³ãé§ä½¿ãã¦DBã¨ããã¨ãããããã¸ãã¯ãçµã¿ç«ã¦ããã¨ã«ãªãã¾ãã ãããä¸æ´åãèµ·ãããããªãå¦çãããããã¨ãã£ã¦éé²ã«ãã©ã³ã¶ã¯ã·ã§ã³ãå¼µã£ããããã©ã³ã¶ã¯ã·ã§ã³ãå¼µããã¦ããããã¨å®å¿ãã¦ã¢ããªã±ã¼ã·ã§ã³å´ã§éé²ã«ãã¸ãã¯ãçµã¿ç«ã¦ã¦ãã¾ãã¨æãã¬ãã°ãçããã¨ã«ãªã£ã¦ãã¾ãã¾ãã ãã®ã¨ã³ããªã§ã¯ãããã©ã³ã¶ã¯ã·ã§ã³ãå¼µã£ã¦ããã°å¤§ä¸å¤«ãã¨ããèãæ¹ã¯å±éºãªå ´åãããã¨ãããã¨ãããããã¡ãªå®è£ ä¾ã交ãã¦ç´¹ä»ãã¦ããã¾ãã 並åã«å¦çããããã©ã³ã¶ã¯ã·ã§ã³ ããããããã©ã³ã¶ã¯ã·ã§ã³ã¯å ¨ã¦ç´åã«å¦çãããã
以åããRDBMSãæ¡ç¨ããã¨ãç¡æã§å¤é¨ãã¼å¶ç´ã¨ããã§ãã¯å¶ç´ã¨ããã©ã³ã¶ã¯ã·ã§ã³ãä»ãã¦ãã¦ãªãã¯ï¼ï¼ï¼ãã¨ããçºè¨ããããã¨ããã£ã¦ããã®èãã¯ä»ããã¾ãå¤ãã£ã¦ããªãã RDBMSã¯åãªã便å©ãªç®±ãããªãã¦ããã¼ã¿ã®æ´åæ§ãå®ãããã®ä»çµã¿ãããããåãã£ã¦ããããã¡ããããããã®ä»çµã¿ã¯ãã¿ããã§ä½¿ããããã§ã¯ãªãããã¼ã¿ã¢ããªã³ã°ãå¦ãã ãããã¼ã¿æ§é ãå¦ãã ãã¨ãããæè³ãã®çµæãã¾ã使ããããã«ãªããã®ã ããã©ã ã¨ããã§åé¡ï¼ï¼ï¼ã¯ãRDBMSã¯å¼·ããããã¨ãããã¨ã§ãã ãã¨ãã°ããã©ã³ã¶ã¯ã·ã§ã³ã®è©±ããæ¬è³ªçã«ã¯ãã©ã³ã¶ã¯ã·ã§ã³æ´åæ§ã§ããå¿ è¦ããªããé 延ãã¦ãã¨ããæ´åæ§ãåãã¦ãã°ãããããªå¦çï¼ã¤ã¾ããçµææ´åæ§ã§ãããããªå¦çï¼ãã¨ããã®ã¯ãæå¤ã¨å¤ãã å¤ãã®éçºã®ç¾å ´ã§ã¯ããã©ã³ã¶ã¯ã·ã§ã³æ´åæ§ãå¿ è¦ã¨ããããçµææ´åæ§ã§ããã®ãã«ã¤ãã¦ãã¾ãèãããã
Kazuhoããã®è«çåé¤ã¯ãªããçãæªããããèªãã§ã UPDATEãçºçããªããã¼ãã«ãªãã°ãåé¤ãã©ã°ã使ã£ãå®è£ ææ³ã§ãç¾å¨ã®ç¶æ ã¨æ´æ°ãã°ãå¥ã ã«è¡¨ç¾ã§ããçµæã¨ãã¦å¹çã¨éå»ã®æ å ±ãåç §ã§ããã¡ãªãããç°¡æ½ã«ä¸¡ç«ã§ããã®ã§ã¯ãªãããã¨ãã話ã 大åæã¨ãã¦å ¨ãåæãªã®ã ãã©ããä»ãããã¼ãã«ã«deleted_atã足ãã ãã§ãéå»ã®ã¬ã³ã¼ãã復æ§å¯è½ãªããã«ãããï¼ï¼ ã¿ããã«æã£ã¡ãã£ãåã®ãããªäººéãå®éã«åãã¹ãå®è£ ææ³ã¯ä½ãããããã¯ããããæ³å®ãã¦ä»ãã£ã¦ããã¹ããã¼ãã«è¨è¨ã¯ã©ããããã®ãï¼ï¼ã¨ããã®ãæå¾ã®çåã ã¾ãUPDATEããªããã°ãimmutableãªãã¹ã¿ãæ´æ°ãã°ããç¾æç¹ã®ãã¥ã¼ãã®ï¼ãã¼ãã«ã¯ãä¾ãã°æ¬¡ã®ããã«ãªãï¼PostgreSQLã®å ´åï¼ï¼ -- immutableãªãã¹ã¿ã create table records ( id serial
ä»æ¥æã¤ãã§è¦ãã¨ã³ããªã¼ãããã§ããã qiita.com è«çåé¤ã®å¼å®³ã¯è²ã ãªã¨ããã§è¨ããã¦ãããã©ãåã®è¶³ããªãé ã§ç解ãã¦ããæã«ããã¨ãäºã¤ã®å¤ããæããªãåé¤ãã©ã°çãªãã®ã¯ã«ã¼ãã£ããªãã£ãäºã ã§æ¤ç´¢æ¡ä»¶ã«ã¤ãã¦ãæ§è½ä¸çã«ããããªãããæå³ããªãã¨ãããã¨ã§ãã è«çåé¤ãå®å ¨ã«æªã ã¨ã¯è¨ãã¾ããããè«çåé¤ã極åæããã人ãã¡ã¯ãåºæ¬çã«ãã¼ã¿ãã®ãã®ãåé¤ããããããã¯è«çåé¤ã¨ããã®ã¯ã¾ã è¦ä»¶çã«æªç¢ºå®ãªè¦ç´ ãé ããã¦ãããã¨ã示ããã©ã°ã§ããã¨èãã¦ããããã§ãã åãITã®æ¥çã§ãã£ãªã¢ãã¹ã¿ã¼ããã¦ãã2å¹´ç®ãããã«é ç½®ãããããã¸ã§ã¯ãã§ã¯TååERææ³ã¨ããã®ããã¼ã¹ã«ãããã¼ãã«è¨è¨ããã¦ãã¦ãããã§ããªãéããããããã§ããããã®æã«ã¯ã ããããã®ãããªååãå©ããã¾ãã¾ããã ãã¼ãã«ã«ç¶æ ãæãããªã 究極ã«ã¯æ©æ¢°ãèªèãããã¼ã¨ã人éã«ã¨ã£ã¦æ
ãè«çåé¤ãäºã ã«ã¤ã㦠- mike-neckã®ããã°ããèªãã§ã ãã¼ã¿ãã¼ã¹è¨è¨ã«ããã¦ãããã¼ãã«ã®æ¸ãæãããããªãimmutableãªãã¹ã¿ã¨æ´æ°ãã°ã«ãã£ã¦å ¨ã¦ãæ§æãããã¨ãããã®è¨äºã®ä¸»å¼µã¯ã¢ããªã³ã°è«ã¨ãã¦å ¨ãæ£ããã ã ããæ®å¿µãªãã¨ã«ããã£ã¹ã¯ãã¡ã¢ãªãè²´éãªè³æºã ã£ãæ代ã®æè¡ã§ããRDBã¯ããã®ãããªã¢ããªã³ã°ã«åºã¥ãã¦è¨è¨ããããã¼ã¿ãã¼ã¹ã«ã¯å¿ ãããé©ãã¦ããªãã 第ä¸ã®åé¡ã¯ãRDBã«å¯¾ãã¦ãªãããæ§ã ãªãæ´æ°ãï¼ãã©ã³ã¶ã¯ã·ã§ã³ï¼ã¯ä¸å®å½¢ï¼ã©ã®ãã¼ãã«ãã©ã®ããã«ä¿®æ£ãããã¯ã¢ããªã±ã¼ã·ã§ã³ä¾åï¼ã ã¨ããç¹ãä¸å®å½¢ãªãæ´æ°ããæç³»åã«ãã£ã¦RDBã«è¨é²ãã¦ããã®ã¯ãè¨è¨ã¨ä¸¦èµ°æ§ã®ç¹ã«ããã¦å°é£ãããã¯ç ©éãªã³ã¼ãã£ã³ã°ãå¿ è¦ã«ãªãï¼ã¨ãããããã®ãããªãã¤ãã³ããã«ãããå¤åãã¯REDOãã°ã«æ¸ãããã®æ´æ°ããããç¶æ ãããã¼ãã«ã«åæ ãã¦ããã¨ããã®ã
ãã¼ã¿ãã¼ã¹æè¡ã®ç¾ éç¤ from Yoshinori Matsunobu ããã¯ç´ æ´ãããè³æã§å¾åã®ãã£ãªã¢ã®è©±ã¨ãé¢ç½ããã ãã©ãä»åæ¸ãã®ã¯p6,p8ã«æ¸ããã¦ããä¸è¨ã®è©±ã§ãã PosgreSQLã¯æ¥ç¶ãããã»ã¹ãã¼ã¹ãªã®ã§LLè¨èªã¨ã®ç¸æ§ããããªã Pgpool(ããã¯ãããã·ãµã¼ãã¼çã«ä½¿ãããã)ãªã©ã®ã³ãã¯ã·ã§ã³ãã¼ã«ã¨ä½µç¨ãããã¨ãå¤ã MySQLã¯æ¥ç¶ãã¹ã¬ãããã¼ã¹ãªã®ã§ã³ãã¯ã·ã§ã³ãã¼ãªã³ã°ã使ãã¥ããLLè¨èªç°å¢ã§ã¯é å ãªãã§LLè¨èªã ã¨ã³ãã¯ã·ã§ã³ãã¼ãªã³ã°ã使ãã¥ããã®ãããããã¤ã¶ãããããªãã©ã¤ããã£ã¦ã¤ãã§ã«ã¡ãã£ã¨åã«è©±é¡ã«ãªã£ãRDBMSã§ã³ãã¯ã·ã§ã³ãã¼ã«ãå¿ è¦ãªçç±ãããããªãã - Togetterã7å¹´åã®ããã°ã¨ã³ããªã§ããã³ãã¯ã·ã§ã³ãã¼ãªã³ã°ã®è©± - naoyaã®ã¯ã¦ãªãã¤ã¢ãªã¼ãèªã¿è¿ãã¦ã¿ã¦æã£ããã¨ãæ¸ãã¦ã¿ããå ¨ç¶ã¾ã¨ã¾ã£ã¦
2013/07/28ã«éå¬ãããqpstudy 2013.07ã®æ親ä¼ã§ãRDBMSã®ã¤ã³ããã¯ã¹ã«é¢ããã¯ã¤ãºLTããã¦ãã¾ããã çºè¡¨è³æã¯ãã¡ãã ã¤ã³ããã¯ã¹ä½¿ãã¦ãï¼ããããããï¼ from Takuto Matsuu è£è¶³äºé çºè¡¨ã§ã¯3ååºé¡ãã¾ããããæ¬å®¶ã®The 3-Minute Test: What do you know about SQL performance?ã¯5åããã¾ããã¤ã³ããã¯ã¹ã«èªä¿¡ãæãæ¹ã¯æ¯éãã£ã¬ã³ã¸ãã¦ã¿ã¦ãã ããã è³æã«ãæ¸ãã¾ããããUse The Index, Luke!ã¯ã¤ã³ããã¯ã¹ãå¦ã¶ãªãå¿ è¦ã®ãµã¤ãã§ããæ¯éã©ããã Use The Index, Luke!ã®å 容ãã¾ã¨ããæ¸ç±SQL PERFORMANCE EXPLAINEDã«ã¤ãã¦ã¯ä»¥åãã®ããã°ã§ç´¹ä»ããã®ã§ãã¡ããã©ãããPDFçãããã¾ãã Use The Index,
snapshot isolationãåæ£ç°å¢ã«é©ç¨ããå ´åã®ãåºæ¬ãã®å 容ã®ã¾ã¨ãã«ãªãã¾ããï¼åºæ¬èªåç¨ã®ã¡ã¢ãªã®ã§ãééã£ã¦ããããã¿ã¾ããï¼ ã¾ãã¯ã¼ãã£ã³ã°ã®æ´ç ã»snapshot isolation TXã®åé¢ã¬ãã«ã¨ãã¦ã®snapshot isolationï¼ä»¥ä¸SIï¼ã¯ãç¾å¨ã®RDBMSã®TX管çã§ã¯ãã»ã¼å®è£ çã«ã¯ããã¡ã¯ãã¨è¦ã¦ããã¨æãã¾ãããã ãANSIã®è¦å®ã®ISOLATION_LEVELã«ã¯å®ç¾©ããªãã®ã§ãã©ã®ãããã«ä½ç½®ã¥ããã®ãã¯ãDBå®è£ ã®ããããã®åãæ±ãã«ããç°ãªãã¾ããã¨ã¯ãããã©ã®DBã§ãã»ã¼SERIALIZABLEã«è¿ãä½ç½®ã¥ãã«ãã¦ããã¨ãããå¤ãã§ãããã¨ããããSIï¼ç¹ã«Serializable SIï¼ãããã§ãªãã¨serializableã«ç¾å®çã«ã¯è¿ã¥ããªãã¨ããã®ãå®æ ãã¨æãã¾ããï¼å¿è«çè«ä¸ã¯S2PLã§å®è£ ã¯å¯è½ã§ãããã¾ããã
æ°å ¥ç¤¾å¡å¿ èªããã¼ã¿ãã¼ã¹ã®åºæ¬ãç解ããã - ãã¼ã¿ãã¼ã¹ã¯ãªãå¿ è¦ãªã®ï¼ï¼ITproã¨ããè¨äºã«å¯¾ãããã¯ãã§æ¬¡ã®ãããªIDã³ã¼ã«ãæ¥ããï¼ç¾å¨ã¯ã³ã¡ã³ãè¿ãã¸ã®ã礼ãå ¥ã£ã¦ããã®ã§ãæåæ°å¶éã®ãããªãªã¸ãã«ã®ã³ã¡ã³ãã¯å°ãåãè©°ãããã¦ãããï¼ "ãªã¬ã¼ã·ã§ãã«ãã¼ã¿ãã¼ã¹ã¯ãã¹ã¦ã®ãã¼ã¿ã2次å ã®è¡¨å½¢å¼ã§è¡¨ç¾"ããããã®ããªã¬ã¼ã·ã§ã³ã2次å æ§é ã¨ãã誤解ã®ä¸ç¨®ãªãã ããããid:nippondanjiãããæ¸ãã¦ããããªã ãã¦ããã®çåã«å¯¾ããæ£è§£ã¯å¦ä½ãªããã®ã ãããï¼ ã¤ãå æ¥ã7ã¤ã®ãã¼ã¿ãã¼ã¹ 7ã¤ã®ä¸çãã®æ¸è©ã§æ¸ããã°ããã ãã»ã»ã» è¨ãã¾ã§ããªããã®éãã§ããã ãªã¬ã¼ã·ã§ã³ã2次å çãªæ§é ãæã£ã¦ããã¨ããã®ã¯å ¸åçãªèª¤è§£ã ãï¼ã¡ãªã¿ã«ãªã¬ã¼ã·ã§ã³ã®æ¬¡å ã¯å±æ§ã®æ°ã«çãããnåã®å±æ§ããããªã¬ã¼ã·ã§ã³ã¯n次å ãï¼ãªã¬ã¼ã·ã§ãã«ã¢ãã«ã«ã¤ãã¦ã¡ããã¨å¦ç¿ãã¦ã
RDBMSã¯ãªã¯ã³ã³ï¼ ãå³ãåãã¦ãå·¦ãåãã¦ãââ ããã°ãã¼ã¿â âã¨ãããã¼ã¯ã¼ããéæ©ããæ代ã«ããã¾ããRDBMSã®è©±é¡ï¼ã æ¬é£è¼ã®ã¿ã¤ãã«ãè¦ã¦ããæãããããããã¾ããã ããã£ã¹ã¯ãã¼ã¹ã®RDBMSã¯ãªã¯ã³ã³ãããããã¯ââï¼ã好ããªã¢ã¼ããã¯ãã£ãå ¥ãã¦ãã ããï¼ã®æ代ã ï¼ã ã¨ãã£ãããæ¹ããããã¨æãã¾ãã ãããããããå¤ãã®ä¼æ¥ãããã°ãã¼ã¿ã«æ³¨ç®ãã¦ãããããã§ãRDBMSå´ã§ã大è¦æ¨¡ãã¼ã¿ãåãæ±ããã¼ãºãå¢ãã¦ãã¾ãã 大è¦æ¨¡ãã¼ã¿ãåãæ±ãæã«ããã«ããã¯ã¨ãªã5ã¤ã®ãã¤ã³ã æ°ç¾ã®ã¬ãã¤ãã¨ãã£ãã¬ãã«ã®RDBMSã§ããã°ãç¾å ´ã®ã¨ã³ã¸ãã¢ã®æ¹ã«ã¨ã£ã¦ã¯ãããã¾ãã®ä¸çã§ãããããããããã©ãã¤ãã大ããè¶ ãããã¼ã¿ãæ±ãå ´åã«ã¯ãããã«ããã¯ã®å¾åãå¤åããã®ã¯ãåãã§ããããã 次ã®å³ã¯ãRDBMSã«ã¾ã¤ããããã«ããã¯ã示ãããã®ã§ãã å³1ã大è¦
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}