On Mon, Jul 5, 2010 at 3:59 PM, Simon Litchfield <si...@slicmedia.com> wrote: >> If you can come up with answers to these points, I might get >> interested. 1 and 2 are fairly trivial; I can think of some obvious >> answers for 3, but 4 is the big problem, and will require some serious >> research and consideration. > > Well, I'm glad you like the with_hints() approach. Items 1-3 are easy. > Re 4 though, every db does it differently. In practice, most don't > need hints like MySQL does <sigh>, because their query optimisers do a > much better job. > > I'd be happy to use raw(); but then you lose len(), slicing, > pagination, filter chaining, etc. My problem came about because admin > change lists were unusably slow on large tables. With_hints allowed a > simple monkey patch to admin, dropping 2s per page down to ~0.01s. > > MySQL is still the most used backend AFAIK, and it's the one that > really needs the hints (poor old thing it is).
I would like to know how you're validating your assertion that MySQL is the most used backend. It doesn't match my experience or observation. The fact that this is a MySQL-specific issue is perhaps the biggest impediment to my enthusiasm about this specific feature (as proposed). I've spent enough time in the past covering for the inadequacies of MySQL. I don't particularly relish the thought of adding more time to that particular ledger. :-) > Adding with_hints() > will only serve to encourage support from other backends too, where > possible. > > Maybe we can make the with_hints() syntax more generic with both > common and backend-specific kwargs -- > > .with_hints(index='my_index') (string implies index on queryset base > model) > .with_hints(index={Model:'my_index', RelatedModel:'index2'}) > (dictionary allows defining index on a per-model basis) > > So the Oracle backend, for example, could implement -- > > .with_hints(hash=True, index={Model:'my_index', > RelatedModel:'index2'}) ( > > On Oracle there are dozens of possible hints, so I'd say unsupported > kwargs could simply be ignored. This would ensure seamless database > portability. Having an implementation ignore kwargs is the obvious approach to providing this feature cross platform. The issue for me is what exactly the kwargs should be, and how they would be interpreted. It isn't clear to be how 'index="my_index"' maps to the application of USE INDEX, IGNORE INDEX or FORCE INDEX in a query, or how the dictionary syntax would map to the situation where you have two appearances of a given table in a query. Yours, Russ Magee %-) -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-develop...@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.