Easy comparing MySQL plans in Django -


This is a way of printing a query from this line of code for example

  Model .objects.all () Order_by (sort_headers.get_order_by ())  

I want to plan the best way to use Django, but together> 10 million objects in my model are getting very slow.

Two options come to mind:

  1. You can see the raw SQL queries described in:

    Ensure that your Django DEBUG setting is set to True then, just do this:

      gt; & Gt; Django.db from import connection & gt; & Gt; & Gt; Connection.queries [{'Election Election_paul Election, poll_paul Q & A, Elections- to Election Commission. For Election Commission, 'Time': '0.002'}]  
  2. You provided as the part of the package Debugschelseil can also see it builds the underlying SQL for each ORM call that returns results in a database query, for example:

      & gt; & Gt; & Gt; From page Import Models Page & gt; & Gt; & Gt; ### Look and use as a result of an additional query ... & gt; & Gt; & Gt; "Page", "page", "page_page", "page_page", "page_page", "page_page", "page_page", "page_page", "page_page", "page", "description" page_page "WHERE" page_page ". " Id "= 1  

Comments