Algorithms
summary
A Sinatra app catalogs a record collection and builds pie charts for the frequency of every value across columns. The first implementation is a mapreduce-like threaded scan that takes about 23.5 seconds for 9,000 items; caching helps but doesn't scale. Replacing the Ruby aggregation with a single SQL GROUP BY query on Postgres drops the same job to ~0.5 seconds, showing use SQL for heavy counting and grouping rather than pulling everything into Ruby.
AI-written summary · about
chapters (4)
related talks
31mProcessing data: Ruby or SQL?
25mPowerful Data: Making Rails Apps Faster with Aggregation
46mUse PostgreSQL, not Rails, to make Rails Faster!
31mUsing Databases to pull your applications weight
37mDenormalizing Rails
26mData indexing with RGB (Ruby, Graphs and Bitmaps)
42mHolistic Database Application Tuning
33mMaking Data Dance
