Use PostgreSQL, not Rails, to make Rails Faster!
summary
Claims that shifting work into PostgreSQL — using arrays, GIN index, hstore/jsonb, window functions and CTEs — removes ActiveRecord churn and cuts latency. Benchmarks on 100k notes show a contains+GIN lookup dropping to 8 ms and array approaches beating joins; returning DB-built JSON payloads yields about 5x faster responses while offloading CPU to Postgres. A small gem prototypes CTE/rank helpers and DB-side jsonb serialization; it works but stresses the database and trades DB load for app-server savings.
AI-written summary · about
chapters (12)
- 0:00Start
- 5:31Tagging
- 5:57Many to Many relation
- 6:22Using Arrays for tags
- 6:40Adding our tags array to the model
- 6:56Finding Tagged Notes
- 8:21Some Benchmarking
- 12:13Single Table Inheritence
- 16:16Leaderboards
- 17:34Using Common Table Expressions to get the ranks of a User's Scores
- 30:28Next Steps
- 32:07Wrapping Up
related talks
23mSupercharging ActiveRecord with PostreSQL
31mUsing Databases to pull your applications weight
43mJust Use Postgres.
42mPostgreSQL Tips & Tricks For App Devs
31mMaking Data Dance
01h 01mNew Approach to Resolve objectrelational impedance mismatch
35mLeveraging PostgreSQL 17's JSONB for Enhanced Data Modeling
30mPuny to Powerful PostgreSQL Rails Apps
