Machine readable explain output
Starting in PostgreSQL 9.0, there are several new formats you can produce EXPLAIN
output in. In addition to the old text format, you can output in XML and JSON, which allows analysis using the rich library of tools found in many programming languages for operating on that sort of data. You can also produce plans in YAML format, which is interesting because it is both machine parsable and arguably easier to read than the standard format. Consider this relatively simple plan:
EXPLAIN SELECT * FROM customers WHERE customerid>1000 ORDER BY zip; QUERY PLAN ---------- Sort (cost=4449.30..4496.80 rows=19000 width=268) Sort Key: zip -> Seq Scan on customers (cost=0.00..726.00 rows=19000 width=268) Filter: (customerid > 1000)
The same plan output in YAML format is much larger, but quite easy to read too:
EXPLAIN (FORMAT YAML) SELECT * FROM customers WHERE customerid>1000 ORDER BY zip; QUERY PLAN ----...