[patch] select_related() additions (depth=N, fields=)
|Reported by:||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||master|
|Cc:||matthias@…, gary.wilson@…, gabor@…||Triage Stage:||Accepted|
|Has patch:||yes||Needs documentation:||yes|
|Needs tests:||yes||Patch needs improvement:||yes|
While I was happy with django's db api, to an extent, it did not have everything needed for the basics. So here is a quick solution to some related fields using select_related().
It adds to parameters to select_related(), depth, and fields.
depth: A numerical field and represents the recursion depth for keys, by default, django recurses infinitely on any keys that are not blank=True
fields: A list of field names in the base model to join with. It does not support children, ie relatedfieldfieldname, but I'd like to add this later, this will also set depth to 1.
I've done several unit tests (several being all of curse-gaming.com) and we're pushing the changes live on the site now. It's helping performance out quite a bit in areas where it was too difficult to manually join with just one other table, or areas where we just wanted top level results.
Change History (27)
comment:1 Changed 10 years ago by
|Summary:||select_related() additions (depth=N, fields=) → [patch] select_related() additions (depth=N, fields=)|
comment:5 Changed 10 years ago by
|Patch needs improvement:||set|
|Triage Stage:||Unreviewed → Accepted|