Grzegorz Olszewski
Grzegorz Olszewski

Reputation: 1418

How can I log query parameters using pg_stat_statements?

I'm trying to identify the heaviest queries in my DB. In the pg_stat_statements, I found a lot of Hibernate-generated queries like:

SELECT this_.ID as ID4_1_, this_.version as version4_1_ [...] where cat1_.name in ($1, $2, $3)

Why there are parameters like $1, $2... $n instead of actual values? Is it possible to log actual values using pg_stat_statements? $n parameters aren't very useful in this case.

I'm using PostgreSQL 9.0.2

Upvotes: 7

Views: 10238

Answers (1)

Craig Ringer
Craig Ringer

Reputation: 324295

pg_stat_statements doesn't log query parameters. That's a large part of the point.

You can use log_statement = all in postgresql.conf if you want full parameter logging.

Another option is to use pg_stat_plans, which collects query plans rather than individual statements.

Upvotes: 12

Related Questions