Thread: Query prepared plan

Query prepared plan

From
Emi Lu
Date:
Good morning,

May I know the "commands" to
. show current session's prepared plans
. see the definition of a prepared plan

E.g., psql> PREPARE fooplan (int, text, bool, numeric) AS INSERT INTO 
foo VALUES($1, $2, $3, $4);

(1) Similar to "\dt", I want to see "fooplan"
(2) Similar to "\d tableName", how to see the plan def?

Thanks a lot!



Re: Query prepared plan

From
Emi Lu
Date:
> Good morning,
> 
> May I know the "commands" to
> . show current session's prepared plans
> . see the definition of a prepared plan
> 
> E.g., psql> PREPARE fooplan (int, text, bool, numeric) AS INSERT INTO 
> foo VALUES($1, $2, $3, $4);
> 
> (1) Similar to "\dt", I want to see "fooplan"
> (2) Similar to "\d tableName", how to see the plan def?


Somebody know about how to find prepared query plan through command line?

Thanks a lot!







Re: Query prepared plan

From
Tom Lane
Date:
Emi Lu <emilu@encs.concordia.ca> writes:
> Somebody know about how to find prepared query plan through command line?
PREPARE fooplan(...)EXPLAIN EXECUTE fooplan(...)
        regards, tom lane


Re: Query prepared plan

From
Emi Lu
Date:
Tom Lane wrote:
> Emi Lu <emilu@encs.concordia.ca> writes:
>> Somebody know about how to find prepared query plan through command line?
> 
>     PREPARE fooplan(...)
>     EXPLAIN EXECUTE fooplan(...)
> 
Thank you Tom.

Similar to \dt to show all tables, within one session, may I know the 
command to list all prepared query plan please?

For example,
[1]\dX   show all defined prepared query plan
[2]\dX planName   show the definition of the named plan.

Thanks a lot!


Re: Query prepared plan

From
Alvaro Herrera
Date:
Emi Lu wrote:

> Similar to \dt to show all tables, within one session, may I know the  
> command to list all prepared query plan please?

select * from pg_prepared_statements;

-- 
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.


Re: Query prepared plan

From
Emi Lu
Date:
>> Similar to \dt to show all tables, within one session, may I know the  
>> command to list all prepared query plan please?
> 
> select * from pg_prepared_statements;

Thank you! I think this is the command.

Too bad that I could not use it under 8.0x.
select * from pg_prepared_statements;
ERROR:  relation "pg_prepared_statements" does not exist
fis=> select version();                                 version
------------------------------------------------------------------------- PostgreSQL 8.0.15 on i686-pc-linux-gnu,
compiledby GCC gcc (GCC) 3.3.2