Thread: Getting result set metadata without executing query?
Is this possible with PostgreSQL? In Sybase, there's a FORMATONLY option, which will not do any disk reads, but instead return a result set with the correct columns, just no tuples. Any facility like this in PostgreSQL? Thanks for your time, Marc. -- I telnetted to whitehouse.gov, and all I got was this lousy .signature!
Marc Ramirez <mrami@mrami.homeunix.org> writes: > Is this possible with PostgreSQL? SELECT * FROM foo LIMIT 0 works in recent releases, though I think not before 7.1 or so. You'd want to avoid anything that involves a SORT step, though, since it's not truly "not executing the query", just abandoning it as soon as the first output row has been generated internally. regards, tom lane
On Wed, 10 Jul 2002, Tom Lane wrote: > Marc Ramirez <mrami@mrami.homeunix.org> writes: > > Is this possible with PostgreSQL? > > SELECT * FROM foo LIMIT 0 > > works in recent releases, though I think not before 7.1 or so. > > You'd want to avoid anything that involves a SORT step, though, > since it's not truly "not executing the query", just abandoning > it as soon as the first output row has been generated internally. Okay. That's cool. The reason I ask is that I have this little utility for Sybase where you give it a query and it generates a C++ class with getters named for the columns, yadda yadda. Maybe if I get ambitious, I might think about adding the functionality. :) Thanks alot, Marc. -- I telnetted to whitehouse.gov, and all I got was this lousy .signature!
I have..... SELECT * FROM foo where true = false; Is this as good as the answer below or does it do an entire table scan? Cheers Tom Ansley On Wednesday 10 July 2002 07:45 am, Tom Lane wrote: > Marc Ramirez <mrami@mrami.homeunix.org> writes: > > Is this possible with PostgreSQL? > > SELECT * FROM foo LIMIT 0 > > works in recent releases, though I think not before 7.1 or so. > > You'd want to avoid anything that involves a SORT step, though, > since it's not truly "not executing the query", just abandoning > it as soon as the first output row has been generated internally. > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly
Tom Ansley <tansley@law.du.edu> writes: > I have..... > SELECT * FROM foo where true = false; > Is this as good as the answer below or does it do an entire table scan? Yeah, that will work (actually you could simplify it to "WHERE false"). However the "LIMIT 0" variant might be a little easier to attach to a prespecified query, which might already have some WHERE clauses. regards, tom lane