From fba93b813f90430545d5acaa25ef218f792360ab Mon Sep 17 00:00:00 2001 From: Chris Adams Date: Thu, 14 Jan 2010 07:35:10 -0800 Subject: Views.py tweaked to use friendlier "EXPLAIN QUERY PLAN" with sqlite3 Signed-off-by: Rob Hudson --- debug_toolbar/views.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'debug_toolbar') diff --git a/debug_toolbar/views.py b/debug_toolbar/views.py index 5a412af..42d3f91 100644 --- a/debug_toolbar/views.py +++ b/debug_toolbar/views.py @@ -77,7 +77,15 @@ def sql_explain(request): if sql.lower().strip().startswith('select'): params = simplejson.loads(params) cursor = connection.cursor() - cursor.execute("EXPLAIN %s" % (sql,), params) + + if settings.DATABASE_ENGINE == "sqlite3": + # SQLite's EXPLAIN dumps the low-level opcodes generated for a query; + # EXPLAIN QUERY PLAN dumps a more human-readable summary + # See http://www.sqlite.org/lang_explain.html for details + cursor.execute("EXPLAIN QUERY PLAN %s" % (sql,), params) + else: + cursor.execute("EXPLAIN %s" % (sql,), params) + headers = [d[0] for d in cursor.description] result = cursor.fetchall() cursor.close() -- cgit v1.2.3