~/talk

Implementing Native Composite Primary Key Support in Rails 7.1

Talkat Rails World 2023 · 2023-10-05..10-06· [ruby-on-rails, databases]
links:none on file
slides:none on file

Rails 7.1 adds native composite primary key support in Active Record with a new query_constraints virtual primary key option, an ID_value attribute to read a lone ID column, and a where by-tuple syntax for bulk loading. Real-world Shopify tests show common selects run 5–6x faster, slow-query volume drops ~80%, while inserts slow ~10x; joint tables and tenant-keyed models benefit most. Associations use composite foreign keys via query_constraints and behave like regular AR associations.

AI-written summary · about

  1. 0:00Introduction to composite keys
  2. 0:55Speaker introduction
  3. 1:50Fundamentals and use cases
  4. 3:04Modeling complex relationships
  5. 4:38Designing database schemas
  6. 5:39Multitenant application design
  7. 6:59Data layout and performance
  8. 8:08Multitenancy performance tradeoffs
  9. 9:41Sharding and composite keys
  10. 11:34Summary of key concepts
  11. 12:08Active Record 7.1 features
  12. 15:30Defining composite key models
  13. 17:08Handling the ID column
  14. 18:25Associations and constraints
  15. 20:11Virtual primary keys
  16. 21:41Conclusion and final notes
~/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.