Revision 3256
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
534 | 534 |
|
535 | 535 |
##### Basic queries |
536 | 536 |
|
537 |
def is_explainable(query): |
|
538 |
# See <http://www.postgresql.org/docs/8.3/static/sql-explain.html#AEN57749> |
|
539 |
return re.match('^(?:SELECT|INSERT|UPDATE|DELETE|VALUES|EXECUTE|DECLARE)\b', |
|
540 |
query) |
|
541 |
|
|
542 |
def explain(db, query): |
|
543 |
return strings.join_lines(values(run_query(db, 'EXPLAIN '+query, |
|
544 |
recover=True, cacheable=True, log_level=3))) |
|
545 |
# not a higher log_level because it's useful to see what query is being |
|
546 |
# run before it's executed, which EXPLAIN effectively provides |
|
547 |
|
|
537 | 548 |
def next_version(name): |
538 | 549 |
version = 1 # first existing name was version 0 |
539 | 550 |
match = re.match(r'^(.*)#(\d+)$', name) |
Also available in: Unified diff
sql.py: Added explain() and is_explainable()