Many-to-many, minus the middleman
summary
An alternative Django ManyToManyField replaces the intermediary table with a Postgres inverted index using Postgres tsquery/tsvector full-text search, claiming queries run at least 2x faster on a ~10 million row dataset and that the supporting index is roughly 100x smaller than a join table. It implements a custom relation via ORM join hooks, is read-only for now, and a Django join-fix patch is accepted for 1.9; code and benchmarks accompany the claim.
AI-written summary · about
chapters (12)
- 0:00Start
- 1:48Navigation hierarchy
- 2:22In Django
- 2:41Selecting books at a node
- 3:04Oops: we need subtrees
- 4:15Subject expressions
- 5:42How does full-text search work?
- 7:06Custom types and lookups
- 9:06Many-to-many mayhem Model
- 11:09Success!
- 12:20Benefits
- 14:40Materialised path
related talks
21mDjango and PostgreSQL: An Even-Closer Union
46mPostgreSQL Beyond Django: Strategies to Get Max Performance with Álvaro Justen
23mDjango with PostgreSQL superpowers
22mDjango with PostgreSQL superpowers
16mBig O No: Django ORM runtime complexity and how to avoid it using LATERAL JOINS
39mdjango-rdflib and postgresql - the best of both worlds
42mDjango ORM: The MTI vs STI Showdown
29mA Pythonic semantic search
