суббота, 17 марта 2012 г. 0:15:39 UTC+6 пользователь dstufft написал:
>
> On Friday, March 16, 2012 at 2:08 PM, Luke Sneeringer wrote:
>
> Here's my hit list of perceived benefits:
> 1. It regains the efficiency of a single table (which is minor, to be 
> sure, but since Jacob already brought it up...)
>
> This issue isn't as minor as one might think I don't believe. I've 
> recently started using the fetch_related thing (which would be the only way 
> to prevent N queries when trying to select a bunch of users + their 
> profiles) and on a table with 20k entries (this isn't User related) where 
> the entries are fairly large the processing time to fetch them all was very 
> significant. This effect would increase with Tom's per app profile issue.
>

If the Profile model has OneToOne relation to User (as suggested in django 
docs [1]) then prefetch_related is not necessary, select_related can be 
used to get all records using single JOIN query. And storing more data in a 
single table could reduce performance, not increase it, because this data 
will be fetched by default even if it is not necessary (+ database will 
have larger rows to search in) - this effect would increase if there are 
several user profiles :) Storing all data in a single table is database 
denormalization: sometimes it can be benifical but should not be default in 
my opinion.

[1] 
https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional-information-about-users

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/1Bt6KG98h8wJ.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to