Reputation: 12376
Given a messy postgres query (e.g. with lots of subqueries) is there a way to figure out what columns will be returned by the query without running the query itself?
If I understand correctly, Sequel's Dataset#columns
method (Documentation) calls the query with a LIMIT 1
attached. That's fine for a simple query, but if subqueries are involved it seems that this approach still results in computing those subqueries.
(One approach might be to add a LIMIT 1 to every subquery, but I'm not exactly sure how to go about doing that.)
I'm using Postgres 9.2 with Sequel.
Thanks! (I know this question isn't as precisely posed as might be desirable -- please let me know what more information I can provide that might be helpful.)
Upvotes: 0
Views: 111
Reputation: 2910
You can do this with explain and add the option VERBOSE. Have a look here
http://www.postgresql.org/docs/9.1/static/sql-explain.html
Upvotes: 1