~/talk

Implementing Native Composite Primary Key Support in Rails 7.1

Talkat RailsConf 2024 · 2024-05-07..05-09· [ruby-on-rails, databases]
links:none on file
slides:none on file

Rails 7.1 adds native composite primary key support so tables can use multiple columns as the primary key, with a new id_value helper to read an ID column when it becomes part of a composite, a where “triple” syntax for bulk queries, and an association option query_constraints that acts as a composite foreign key or virtual primary key. Shopify migration shows the tradeoff concretely: about 5x faster queries for tenant-scoped reads but roughly 10x slower inserts after switching to composite keys.

AI-written summary · about

  1. 0:00Introduction
  2. 2:18Fundamentals
  3. 5:04Multitenant Applications
  4. 11:02Tenant Based Sharding
  5. 13:41Composite Primary Keys
  6. 16:33Where Query
  7. 17:12Constraints
  8. 18:32Virtual Primary Key
  9. 19:45Conclusion
~/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.