On Wed, Feb 09, 2005 at 06:31:11PM -0800, David Fetter wrote: > On Wed, Feb 09, 2005 at 04:34:30PM -0700, Ed L. wrote: > > > > SELECT sql, op, index, relation, actual_first > > FROM pg_explain_analyze('SELECT * FROM foo') > > WHERE op = 'Index Scan' > > AND actual_first > 1.0; > > > > Thankfully, I'm sure there are a lot of skilled postgresql'ers > > just sitting around right now wishing they had something to do. > > Well, I'm a little bored; I've got tomorrow off, and this seems like > it might be doable in the kind of high-level PL/Foo's with which I'm > familiar. What would the returning rowtype for > pg_explain_analyze(TEXT) be? I started looking at this earlier. Is it even possible to get EXPLAIN output via SPI (and thus the PLs' interfaces to SPI)? Or would the function have to make a new connection to the database and issue the EXPLAIN as an ordinary client? I suppose a proper implementation would be written in C and would call the internal functions that generate the output, but I was thinking about how to do something simple in a higher-level PL. As for the return type, I was going to look at explain_outNode() in src/backend/commands/explain.c and get some ideas from there. -- Michael Fuhr http://www.fuhr.org/~mfuhr/ ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match