#12192: Don't execute sql query with limit 0 ---------------------------------------------------+------------------------ Reporter: Suor | Owner: ramiro Status: new | Milestone: Component: Database layer (models, ORM) | Version: 1.1 Resolution: | Keywords: Stage: Design decision needed | Has_patch: 1 Needs_docs: 0 | Needs_tests: 0 Needs_better_patch: 0 | ---------------------------------------------------+------------------------ Changes (by ramiro):
* needs_better_patch: => 0 * needs_tests: => 0 * owner: nobody => ramiro * needs_docs: => 0 * has_patch: 0 => 1 * stage: Unreviewed => Design decision needed Comment: I've attached two patches that implement detection of the `high_mark == low_mark` condition and avoid going to the DB with such a query, the second patch could be even slightly more efficient because it shortcuts execution of `Query.as_sql()` early completely avoiding the setup and generation of the SQL query text. One thing to review and decide is that isn't clear from the docstrings and comments what `Query.as_sql()` is supposed to return to signal no SQL query text was generated. The patches currently return an empty string but I don't know now if it should be None. Tests that exercise this already exist in `modeltests/basic` and `regressiontests/queries`. -- Ticket URL: <http://code.djangoproject.com/ticket/12192#comment:1> Django <http://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-upda...@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.