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

Reply via email to