~/talk

Geolocation EXPLAINed

Talkat RailsConf 2022 · 2022-05-17..05-19· [databases, web-performance]
slides:none on file

Builds a geolocation lookup using MaxMind data in two tables (network_blocks → network_locations), Rails, and Postgres, parsing CIDR to range-search IPs. Initial query does a sequential scan over ~1M of 3M rows and costs ~200 ms. Using Postgres EXPLAIN ANALYZE reveals a nested-loop plus seq scan; adding an index on start/end IPs and an ORDER to force an index scan drops runtime to ~1.67 ms — over 100× faster — so the system works and scales.

AI-written summary · about

  1. 0:00Geolocation challenges
  2. 2:50Geolocation problem and goals
  3. 3:10Initial geolocation options
  4. 4:11MaxMind geolocation data
  5. 5:12CIDR notation for IP ranges
  6. 7:44Geolocation lookup in Rails
  7. 9:30Performance bottlenecks with New Relic
  8. 10:34EXPLAIN ANALYZE for slow queries
  9. 12:42Sequential vs index scan
  10. 16:14Nested loop joins impact
  11. 18:03B-tree indexes for search speed
  12. 21:57Indexing trade-offs with writes
  13. 23:22Optimizing geolocation query
  14. 24:44PostgreSQL query plan tuning
  15. 26:10Query optimization gains
  16. 26:55Summary
~/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.