Getting truncated queries from pg_stat_statements

From: Tim Uckun <timuckun(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Getting truncated queries from pg_stat_statements
Date: 2015-01-19 22:37:10
Message-ID: CAGuHJrO2viJCiETi9EGBxKL+_1tMSYOtq9HRf5EQHY+HC3idbQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am trying to get some slow query information and the results from my
query are truncated at 2047 characters. Some of my queries are very long
so they get truncated in the select. Is there a way around this?

Here is my query.

WITH query_stats AS (
SELECT
query::text,
(total_time / 1000 / 60) as total_minutes,
(total_time / calls) as average_time,
calls
FROM
pg_stat_statements
INNER JOIN
pg_database ON pg_database.oid = pg_stat_statements.dbid
WHERE
pg_database.datname = current_database()
)
SELECT
query,
total_minutes,
average_time,
calls,
total_minutes * 100.0 / (SELECT SUM(total_minutes) FROM
query_stats) AS total_percent
FROM
query_stats
WHERE
calls >= 10
AND average_time >= 20
ORDER BY
average_time DESC
LIMIT 100

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Peter Geoghegan 2015-01-19 23:15:09 Re: Getting truncated queries from pg_stat_statements
Previous Message Stefan Keller 2015-01-19 22:07:57 Re: splitting up tables based on read/write frequency of columns