Biggish Data with Rails and Postgres

Biggish Data with Rails and Postgres

Tips and tricks for scaling Rails apps with large databases.

Given at RubyNation 2014

9b0968d25731bc92a98c3e0b77e6d2ce?s=128

Benjamin Curtis

June 06, 2014
Tweet

Transcript

  1. 12.

    db=# EXPLAIN (format yaml) SELECT count(*) FROM errors; QUERY PLAN

    -------------------------------------- - Plan: + Node Type: "Aggregate" + Total Cost: 49971.71 + Plan Rows: 1 + Plans: + - Node Type: "Seq Scan" + Relation Name: “errors" + Total Cost: 48172.96 + Plan Rows: 719496 +
  2. 14.

    db=# EXPLAIN ANALYZE SELECT id FROM errors OFFSET 500000 LIMIT

    100; ! QUERY PLAN -------------------------------------- - Plan: + Node Type: "Limit" + Actual Rows: 100 + Plans: + - Node Type: "Seq Scan" + Relation Name: "errors" + Actual Rows: 500100 +
  3. 15.

    db=# EXPLAIN ANALYZE SELECT msg FROM errors WHERE id >=

    500000 AND id < 500100; ! QUERY PLAN -------------------------------------------------------- - Plan: + Node Type: "Bitmap Heap Scan" + Relation Name: "errors" + Actual Rows: 100 + Plans: + - Node Type: "Bitmap Index Scan" + Index Name: "errors_pkey" + Total Cost: 5.42 + Actual Rows: 100 + Index Cond: "((id >= 500000) AND (id <= 500100))"