ISUCONåããã§ä½ã£ããã¤ç¬¬nå¼¾ã§ãã*1
ã¢ããã¼ã·ã§ã³
達人が教えるWebパフォーマンスチューニング 〜ISUCONから学ぶ高速化の実践:書籍案内|技術評論社ï¼é称ISUCONæ¬ï¼ ãèªãã§ãæã«
SELECT `posts`.`id`, `posts`.`user_id`, `posts`.`body`, `users`.`account_name` AS `users.account_name`, `users`.`authority` AS `users.authority`, `users`.`del_flg` AS `users.del_flg` FROM `posts` INNER JOIN `users` ON `posts`.`user_id` = `users`.`id`
ã®ããã«ã«ã©ã åããããå«ã¾ããSELECTæã https://github.com/jmoiron/sqlx ã«æ¸¡ã㨠users
ã®é¨åãããæãã«Goã®structã«è©°ãæ¿ãã¦ãããã¨æ¸ããã¦ããã®ã§ãããRubyã§ãåããã¨ãããããã¦ã¢ã³ãã¼ãããgemãä½ãã¾ããã
使ãæ¹
READMEãå
¨ã¦ãªãã§ããã using Mysql2::NestedHashBind::QueryExtension
ãæ¸ããã¹ã³ã¼ã㧠Mysql2::Client#query
㨠Mysql2::Client#xquery
ã«ã¢ã³ãã¼ããããä»è¾¼ã¿ã¾ãã
require "mysql2-nested_hash_bind" using Mysql2::NestedHashBind::QueryExtension db = Mysql2::Client.new( host: ENV.fetch("MYSQL_HOST", "127.0.0.1"), port: ENV.fetch("MYSQL_PORT", "3306"), username: ENV.fetch("MYSQL_USERNAME"), database: ENV.fetch("MYSQL_DATABASE"), password: ENV.fetch("MYSQL_PASSWORD", ""), charset: "utf8mb4", database_timezone: :local, cast_booleans: true, symbolize_keys: true, reconnect: true, ) rows = db.query(<<~SQL) SELECT `posts`.`id`, `posts`.`user_id`, `posts`.`body`, `users`.`account_name` AS `users.account_name`, `users`.`authority` AS `users.authority`, `users`.`del_flg` AS `users.del_flg` FROM `posts` INNER JOIN `users` ON `posts`.`user_id` = `users`.`id` SQL rows.first #=> {:id=>1, :user_id=>445, :body=>"test", :users=>{:account_name=>"sue445", :authority=>false, :del_flg=>false}}
é å¼µããã¤ã³ã
ISUCONã§å©ç¨ããã¨ãããã¨ã§ããã©ã¼ãã³ã¹ãã¥ã¼ãã³ã°ãé å¼µãã¾ããã
å ·ä½çã«ã¯ https://github.com/evanphx/benchmark-ips ã§ãã³ããã¼ã¯ãã¨ãã¤ã¤ https://github.com/tmm1/stackprof ã§gemã®ããã«ããã¯ã調ã¹ã¦ããã«ããã¯ã«ãªã£ã¦ãç®æãæ¹åãã¦ã¾ãã
stackprofã§è¦ã¤ãã£ãããã«ããã¯ã®1ã¤ã« Symbol#to_s
ããã£ãã®ã§freezeãããStringãè¿ã Symbol#name
ã使ããã¨ããã®ã§ãããSymbol#name
ã使ããã®ãRuby 3.0以éã ã£ãã®ã§ãã®gemãRuby 3.0以éã§ãã使ããªãããã«ãã¦ã¾ãã
ãã³ããã¼ã¯ã®ã³ã¼ãã¨ã¬ãã¼ã㯠https://github.com/sue445/mysql2-nested_hash_bind/tree/main/benchmark ã«ç½®ãã¦ããã®ã§ã©ãããããªã¼ãã¼ããããããã¯ãããè¦ã¦ãã ããã