Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ActiveRecord::PostgreSQLAnalyzer gem を作った話 #m3dev

ActiveRecord::PostgreSQLAnalyzer gem を作った話 #m3dev

M3 Tech Talk で「ActiveRecord::PostgreSQLAnalyzer gem を作った話」というタイトルで LT したときの資料です。
#m3dev

Takayuki Matsubara

December 22, 2015
Tweet

More Decks by Takayuki Matsubara

Other Decks in Programming

Transcript

  1. Output logfile if sequential scan is detected ------------ find Seq

    Scan query ------------ SELECT "todo".* FROM "todo" WHERE "todo"."user_id" = $1 LIMIT 1 QUERY PLAN --------------------------------------------------------------------------------------------- Limit (cost=10000000000.00..10000000001.67 rows=1 width=81) -> Seq Scan on todo (cost=10000000000.00..10000000001.67 rows=1 width=81) Filter: (user_id = 13) (3 rows)
  2. Detect Sequential Scan SELECT "todo".* FROM "todo" WHERE "todo"."user_id" =

    $1 LIMIT 1 QUERY PLAN --------------------------------------------------------------------------------------------- Limit (cost=10000000000.00..10000000001.67 rows=1 width=81) -> Seq Scan on todo (cost=10000000000.00..10000000001.67 rows=1 width=81) Filter: (user_id = 13) (3 rows) https://github.com/m3dev/ active_record-postgresql_analyzer/ blob/master/lib/active_record/ postgresql_analyzer.rb#L23
  3. end