~/talk

Supercharging ActiveRecord with PostreSQL

Talkat Wicked Good Ruby 2013 · 2013-10-12..10-13· [ruby, databases]
links:none on file
slides:none on file

Rails 4 ActiveRecord actually supports PostgreSQL arrays, hstore and ranges so the database does filtering and constraints instead of Ruby code; a GIN index on arrays yields roughly 50× speed in the presenter’s benchmark of 100,000 notes with 100 tags each and 10,000 possible tags; hstore values come back as strings so numbers need casting; use rank() window + CTE to compute correct leaderboard ranks without loading all scores into memory.

AI-written summary · about

  1. 0:00Start
  2. 0:29Supercharging ActiveRecord with PostgreSQL
  3. 1:51What We'll Explore: Arrays • PostgreSQL has built in support for arrays of any datatype That includes user-defined types as well • Can be multi-dimensional • Child arrays must have the same number of elements as their siblings
  4. 7:50Some Benchmarking • 100,000 notes, each with 100 tags • 10,000 possible tags • Table was cached by scanning it once • Run on a MacBook Pro Retina with 16GB of RAM and SSD • Noticeably slower reads on a Mac Mini with spinning metal
  5. 20:35Wrapping Up • PostgreSQL has some really powerful features baked in • Your situation ultimately dictates the best approach • Play with different solutions to see what is the best performance/maintainability trade off for your specific use case • Don't just use it because "It's new/cool"
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.