On Wed, Aug 25, 2010 at 5:11 AM, Michael Manfre <mman...@gmail.com> wrote: > I don't think namespacing is a valid objection against query hints. By > design, query hints are specific to a database version and if a > generic django app were to include them, then the author is doing > something wrong or setting the expectation of only supporting a very > specific environment.
I don't follow your logic here. If I'm writing a reusable app, I define some models, and I define the views that use those models. Those views issue queries. Therefore, I know both the tables that are involved, and the queries that will be issued on those tables. If I'm really tuning things, I might even be using custom SQL, shipped with my project, to create custom indices for those tables. Since I'm in control of the table and how the table is used, I should also be in a position to provide any query plan hints that will assist the known usage patterns. If I'm distributing my application to many people, different people in my audience will be using different databases. That puts me in a position of (potentially) having to provide hints for multiple databases as part of my shipped application. Therefore, there is a namespace problem. I need MySQL hints to be applied for users that have MySQL. I need Oracle hints to be applied for users that have Oracle, ignoring the MySQL hints. I need Postgres to ignore any hint that is applied. On top of that, there's a possibility that a hint name (and value format) for one database might clash with another. I don't know of any specific examples of overlap, but it isn't hard to manufacture one using generic hinting keywords like "index = foo". > Any core implementation for supporting this > should be minimalist and only provide a mechanism for passing some > kind of data from the QuerySet to the SQLCompiler that each backend > can optionally choose to do something with it. > > I would be thrilled to be able to do use > > with_hints('HASH GROUP', 'FAST 10') > > and have it set > > Query.query_hints = ['HASH GROUP', 'FAST 10'] > > I'm currently patching in support so I can do something like this for > django-mssql. And that's the proposal on the table, except that you would need to specify that this is a MSSQL hint, since the hint you're making isn't of any use to a user of any database other than MSSQL. 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.