7

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

2
  • Upgrade to the latest point release, your version has a major security hole and some serious known bugs. Commented Sep 11, 2014 at 1:57
  • Unfortunately it's up to the client, I can only suggest an upgrade. Commented Sep 11, 2014 at 10:28

1 Answer 1

13

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.

Sign up to request clarification or add additional context in comments.

2 Comments

"Large part of the point": for clarity, pg_stat_statements summarizes query performance based on normalized, non-parameterized versions of the actual queries, so each row in pg_stat_statements potentially represents multiple queries with different parameters. Also pg_stat_plans hasn't been updated since 2013 (github.com/2ndQuadrant/pg_stat_plans/issues/40), so logging or auto_explain may be better approaches.
Yeah, pg_stat_plans was meant to be merged into core to replace/enhance pg_stat_statements but got stuck IIRC.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.