~/talk

500X Memory Reduction In Rails With Postgres Schemas And Apartment

Talkat RubyConf MY 2017 · 2017-10-12..10-13· [ruby-on-rails, databases]
links:none on file
slides:none on file

A Rails app using Postgres multi‑schema with Apartment cuts memory by 500x memory reduction after changing how Postgres types are loaded: ActiveRecord no longer loads duplicate composite types per schema, reducing pg_type rows from ~420,000 to ~163 in a 10,000‑schema test, and avoiding repeated expensive OID lookups by adding a cache pg_type results layer and a small patch to filter pg_type entries; production with ~200k schemas becomes stable and migrations remain painful but possible.

AI-written summary · about

  1. 0:00Introduction and speaker intro
  2. 1:38About the company and speaker
  3. 3:28Memory problem overview
  4. 5:37Multi-tenancy and schema structure
  5. 8:10Debugging production memory issues
  6. 9:11Database size impact on memory
  7. 11:21Root cause of memory consumption
  8. 13:51Solution and code modifications
  9. 16:22Caching mechanism implementation
  10. 17:08Why others don't face this issue
  11. 19:39Refactoring multi-schema structure
  12. 21:06Q&A session begins
~/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.