-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Anssi,
On 02/18/2012 05:37 AM, Anssi Kääriäinen wrote: > The second one is about .iterator() and .prefetch_related() > interoperability. They are mutually exclusive (you need to fetch all > the objects before you can do prefetch. However, .iterator() says do > not fetch all the objects in one go...). There are basically three > ways forward: raise an error, favor .iterator() (current behavior) or > favor .prefetch_related(). > > I think each one has some merit, and this is mostly bike-shedding. > However, if you have good reasons for one of the options it would be > good to hear them now. I would prefer either error or doing the > prefetch even when iterator is used. As I don't recall ever actually > using .iterator() in production I have no strong opinions. The ticket > is #17668. I don't have a real strong opinion here either, but I think this rarity of usage of .iterator() is an argument for favoring it. In my experience, if you are bothering to use .iterator() it's because you really know you need it; you are fetching a ton of items and loading them all at once might run your server out of memory. Whereas the consequence of ignoring prefetch_related is just extra SQL queries - bad, but less likely to be catastrophic. That's all kind of handwavy, but in the absence of good hard reasons in either direction, it's the best I've got :-) Really, silently ignoring either one gives me a bit of a bad taste. I understand Luke's reasoning for not raising an error; you might not control the whole queryset construction chain, and unpredictable errors are bad. But I wish there were some way we could alert the developer of the situation. I guess anyone who really needs the prefetch_related is probably monitoring their SQL queries, and is likely to notice the extra SQL queries pretty quickly. Carl -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk9BJeUACgkQ8W4rlRKtE2fcjgCbBudTE6UjRCTRashf6mZ5PNzI toUAnRIatUAfQVw33mlbAp6W3Mx0ofHg =UCkj -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Django developers" group. 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.