cte-debug Postgres CTE debugger -- quick and dirty This won't work for all queries, but for the ones I needed to debug, its works great. Copy config.py.sample to config.py and then fill out the missing fields in config.py. Then run cte_debug.py .