Search code examples
postgresqlpgbouncer

Viewing parameterized query logs in PostgreSQL & Pg-Bouncer?


In my PostgreSQL logs (I'm using PG-BOUNCER, too). I'm not able to view the query that is causing me issues.

I have not tried anything too specific at this time as I'm wondering if there's a good way to do this with PG-BOUNCER.

Here's the problem:

select * from x where y = $1

The parameter $1 is the only thing I can see in the logs from the PostgreSQL side.

What strategy is there with PG-BOUNCER in mind, to get the raw data from that parameter to see what query is potentially causing issues?


Solution

  • If you run into this situation, an answer is to use:

    ALTER DATABASE db_name SET statement_timeout to '30s';
    

    When a bad parameterized query occurs, it'll timeout and you'll see the $1 value that was previously hidden in the logs.