-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Description
Example:
foo=# select * from pg_stat_plans where planid = 4291451842;
-[ RECORD 1 ]-------+-------------------------------------------------------------------
planid | 4291451842
userid | 16384
dbid | 126346
query | insert into test(foo) values(7); insert into test(foo) values(11);
had_our_search_path | t
from_our_database | t
query_explainable | t
calls | 12
total_time | 0.532
rows | 12
shared_blks_hit | 65
shared_blks_read | 1
shared_blks_written | 0
local_blks_hit | 0
local_blks_read | 0
local_blks_written | 0
temp_blks_read | 0
temp_blks_written | 0
blk_read_time | 0
blk_write_time | 0
last_startup_cost | 0
last_total_cost | 0.015
foo=# truncate table test;
TRUNCATE TABLE
foo=# select * from test;
(No rows)
foo=# select pg_stat_plans_explain(4291451842, 16384, 126346);
-[ RECORD 1 ]---------+-------------------------------------------------
pg_stat_plans_explain | Insert on test (cost=0.00..0.01 rows=1 width=0)
| -> Result (cost=0.00..0.01 rows=1 width=0)
foo=# select * from test;
-[ RECORD 1 ]
id | 82
foo | 11
To reproduce:
Generate a multi-statement entry in pg_stat_plans, e.g. with python/psycopg2. Doesn't seem to work from within psql.
#!/usr/bin/env python
import psycopg2
conn = psycopg2.connect("dbname='foo'")
curs = conn.cursor()
query = 'insert into test(foo) values(7); insert into test(foo) values(11);'
curs.execute(query)
conn.commit()
pg_stat_plans_explain will execute everything after the first semicolon/query literal.
Metadata
Metadata
Assignees
Labels
No labels