#20516: Allow use of prepared statements -------------------------------------+------------------------------------- Reporter: est | Owner: nobody Type: New feature | Status: new Component: Database layer | Version: master (models, ORM) | Resolution: Severity: Normal | Triage Stage: Accepted Keywords: db, prepared | Needs documentation: 0 statement | Patch needs improvement: 0 Has patch: 0 | UI/UX: 0 Needs tests: 0 | Easy pickings: 0 | -------------------------------------+------------------------------------- Changes (by akaariai):
* needs_better_patch: => 0 * needs_tests: => 0 * version: 1.6-alpha-1 => master * keywords: db, mysql, prepared statement => db, prepared statement * needs_docs: => 0 * stage: Unreviewed => Accepted Comment: Yes, I think addition of prepared statements is something to consider. No idea of what would be a nice API, or if this could be somehow delegated to third party apps. The latter option means some hooks are needed somewhere in the query execution path. One such point is execute_sql() where it would be fairly straightforward to change the used SQL to prepared statements if the query is set to use prepared statements. FWIW there are use cases where prepared statements can give easily over 50% speedup. Such cases are simple to execute queries which retrieve just a few rows of data, but which have a massive amount of joins (so that planning overhead is big). Using .select_related() and complicated .filter() clauses are easy ways to produce such queries. I don't see any reason to restrict this to MySQL only. (This feature seems to need at least these parts: - API for setting given queryset to use prepared statements - using them automatically is generally a bad idea - Convert the query's execution to use prepared statement instead of SQL. This consists of: - A check if the given query is already prepared for the used connection - If so, use the correct prepared statement - If not, create a new prepared statement and use that) -- Ticket URL: <https://code.djangoproject.com/ticket/20516#comment:1> 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 unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/061.8684f050e9a1ea629264a9b73ada0766%40djangoproject.com. For more options, visit https://groups.google.com/groups/opt_out.