#17000: sql/query.py add_q refactoring
-------------------------------------+-------------------------------------
     Reporter:  akaariai             |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |                  Version:  1.3
    Component:  Database layer       |               Resolution:
  (models, ORM)                      |             Triage Stage:  Design
     Severity:  Normal               |  decision needed
     Keywords:                       |      Needs documentation:  0
    Has patch:  1                    |  Patch needs improvement:  0
  Needs tests:  0                    |                    UI/UX:  0
Easy pickings:  0                    |
-------------------------------------+-------------------------------------

Comment (by akaariai):

 I used the above idea and now I have something clean and nice implemented.
 Same branch as above. The patch needs some cleanup still, but otherwise it
 is pretty much ready. If nothing else, check the new add_q and _add_q
 implementations. Now, that is cleaner than before, right?

 When committing this, the correct approach is to first commit the
 wherenode.as_sql() refactoring [https://github.com/django/django/pull/92],
 then rebase this patchset on that work.

 I removed a short-cut of "any object having 'add_to_query' attribute will
 can add itself directly to the query". This isn't tested or documented,
 and to me it seems any such add_to_query object must use deep internals of
 the ORM, and has been likely broken multiple times already since its
 introduction. Any objections of removing this?

 The patch seems to be little faster than before using djangobench.
 query_filter_chaining is around 5-10% faster, other query operations maybe
 2-3% faster and query_in_bulk around 5% slower. The reason for in_bulk
 slowdown is that it now uses public APIs instead of internal APIs of the
 inner query class. The test in djangobench is for fetch __one__ object by
 using in_bulk and is hardly relevant for any real use case anyways. If the
 fetch was for 10 objects, I doubt if there would be any significant speed
 difference.

 After this gets committed, a larger refactor of the lookup system could be
 the next step.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/17000#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

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

Reply via email to