# PostgreSQL Query is trimming in the QAN dashboard

**URL:** <https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879>\
**Category:** Percona Monitoring and Management (PMM)\
**Created:** [September 3, 2024, 10:49am UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879 "2024-09-03T10:49:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [September 3, 2024, 10:49am UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/1 "2024-09-03T10:49:10Z")

</div>

Hi Team,

We can only view half of the query, as the query has been truncated in the QAN.  
Could you please tell me how I may retrieve the whole query in the QAN?

---

<div class="post-metadata">

**Author:** ![Robert\_Bernier](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/robert_bernier/32/1367_2.png) [@Robert\_Bernier](https://forums.percona.com/u/Robert_Bernier)\
**Post date:** [September 3, 2024, 1:11pm UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/2 "2024-09-03T13:11:24Z")

</div>

Hi,

As per the postgres documentation …

> `track_activity_query_size` (`integer`)
> 
> Specifies the amount of memory reserved to store the text of the currently executing command for each active session, for the `pg_stat_activity`.`query` field. If this value is specified without units, it is taken as bytes. The default value is 1024 bytes. This parameter can only be set at server start.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [September 3, 2024, 1:49pm UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/3 "2024-09-03T13:49:24Z")

</div>

Thanks @Robert_Bernier for the quick response.

Is there any performance impact if we increase the ‘track\_activity\_query\_size’ parameter in the PostgreSQL database, however we did not specify anything for Mariadb, therefore I am simply curious on the DB performance.

---

<div class="post-metadata">

**Author:** ![Robert\_Bernier](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/robert_bernier/32/1367_2.png) [@Robert\_Bernier](https://forums.percona.com/u/Robert_Bernier)\
**Post date:** [September 3, 2024, 1:51pm UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/4 "2024-09-03T13:51:51Z")

</div>

No performance impact.

regards 🙂

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [September 3, 2024, 2:12pm UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/5 "2024-09-03T14:12:56Z")

</div>

Thanks to @Robert_Bernier for all the information.

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [September 4, 2024, 9:53am UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/6 "2024-09-04T09:53:20Z")

</div>

Hi @Robert_Bernier

I have checked in the DB, and I can see only 2KB. But the default value is 1024 bytes.

## postgres=# postgres=# show track\_activity\_query\_size ; track\_activity\_query\_size

2kB  
(1 row)

postgres=#  
postgres=#

**I have already set to 2GB. but still its showing 2 KB.**

[postgres@rntpgd201 12]$ cat /db/pgdata/12/postgresql.conf |grep -i ‘track\_activity\_query\_size’  
#track\_activity\_query\_size = 1024 # (change requires restart)  
track\_activity\_query\_size = 2048 # Increase tracked query string size  
[postgres@rntpgd201 12]$

---

<div class="post-metadata">

**Author:** ![Robert\_Bernier](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/robert_bernier/32/1367_2.png) [@Robert\_Bernier](https://forums.percona.com/u/Robert_Bernier)\
**Post date:** [September 4, 2024, 3:20pm UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/7 "2024-09-04T15:20:34Z")

</div>

There’s a hardcoded limit of 100KB so you can’t go to 2GB. As per your message, you also have to restart the server for the new parameter to take effect.

> – server restart is required  
> alter system set track\_activity\_query\_size=‘100kB’;

Hope this helps.

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [September 4, 2024, 4:17pm UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/8 "2024-09-04T16:17:51Z")

</div>

Hi @Robert_Bernier

Unfortunately, the postgresql.log file contains the entire query, whereas QAN just contains the trimmed query (half of the query).

---

<div class="post-metadata">

**Author:** ![Robert\_Bernier](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/robert_bernier/32/1367_2.png) [@Robert\_Bernier](https://forums.percona.com/u/Robert_Bernier)\
**Post date:** [September 4, 2024, 6:06pm UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/9 "2024-09-04T18:06:39Z")

</div>

They PMM maintainers have asked me “_What is the string length of your query_”?

---

<div class="post-metadata">

**Author:** ![Robert\_Bernier](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/robert_bernier/32/1367_2.png) [@Robert\_Bernier](https://forums.percona.com/u/Robert_Bernier)\
**Post date:** [September 4, 2024, 6:15pm UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/10 "2024-09-04T18:15:27Z")

</div>

Following up …

You need to remove and add the server again in order to perform the following

`pmm-admin add postgresql server-1 --max-query-length=3072`

---

<div class="post-metadata">

**Author:** ![Robert\_Bernier](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/robert_bernier/32/1367_2.png) [@Robert\_Bernier](https://forums.percona.com/u/Robert_Bernier)\
**Post date:** [September 4, 2024, 6:18pm UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/11 "2024-09-04T18:18:50Z")

</div>

and this bug [report](https://perconadev.atlassian.net/browse/PMM-13288?atlOrigin=eyJpIjoiMzJmYmY3MGE0YTUxNDBjZTgzYzJkMDQxYjJlMTdkMzEiLCJwIjoiamlyYS1zbGFjay1pbnQifQ) …

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [September 4, 2024, 7:05pm UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/12 "2024-09-04T19:05:02Z")

</div>

Thanks @Robert_Bernier

I’ll try the above option and let you know what happens.

---

<div class="post-metadata">

**Author:** ![Roma\_Novikov](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/roma_novikov/32/1161_2.png) [@Roma\_Novikov](https://forums.percona.com/u/Roma_Novikov)\
**Post date:** [September 5, 2024, 9:54am UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/13 "2024-09-05T09:54:05Z")

</div>

@Naresh9999, what do you use inside PostgreSQL pg\_stat\_statements or pg\_stat\_monitor ?

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [September 5, 2024, 10:49am UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/14 "2024-09-05T10:49:13Z")

</div>

@Roma_Novikov

We are utilizing both the monitors.

## sds=# show shared\_preload\_libraries; shared\_preload\_libraries

pgaudit, pgauditlogtofile, pg\_stat\_statements, pg\_stat\_monitor  
(1 row)

## sds=# SELECT pg\_stat\_monitor\_version(); pg\_stat\_monitor\_version

2.0.1  
(1 row)

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [September 5, 2024, 11:36am UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/15 "2024-09-05T11:36:13Z")

</div>

Hi @Robert_Bernier

Still, I can see only the trimmed query.

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [September 6, 2024, 6:28am UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/16 "2024-09-06T06:28:28Z")

</div>

Hi @Roma_Novikov

Any thoughts on this issue? Am I missing something here? This is how I have added the PostgreSQL servers in the PMM.

pmm-admin add postgresql --server-insecure-tls --username=‘pmm\_usr’ --password=‘xxxxxxxxxxxx’ --host=‘10.112.xx.xx’ --port=5432 --service-name=C-QA-xxxx --query-source=“pgstatmonitor” --max-query-length=3072 --environment=C-QA

---

<div class="post-metadata">

**Author:** ![Roma\_Novikov](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/roma_novikov/32/1161_2.png) [@Roma\_Novikov](https://forums.percona.com/u/Roma_Novikov)\
**Post date:** [September 6, 2024, 10:28am UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/17 "2024-09-06T10:28:15Z")

</div>

@Naresh9999 check the data you have in [`pg_stat_monitor` view reference - pg\_stat\_monitor Documentation](https://docs.percona.com/pg-stat-monitor/reference.html#pg_stat_monitor-view-reference)  
Are there full queries collected?

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [September 6, 2024, 10:42am UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/18 "2024-09-06T10:42:23Z")

</div>

Hi @Roma_Novikov

I can see the below output.

sds=# \d pg\_stat\_monitor;  
View “public.pg\_stat\_monitor”  
Column | Type | Collation | Nullable | Default  
---------------------±-------------------------±----------±---------±--------  
bucket | bigint | | |  
bucket\_start\_time | timestamp with time zone | | |  
userid | oid | | |  
username | text | | |  
dbid | oid | | |  
datname | text | | |  
client\_ip | inet | | |  
pgsm\_query\_id | bigint | | |  
queryid | bigint | | |  
top\_queryid | bigint | | |  
query | text | | |  
comments | text | | |  
planid | bigint | | |  
query\_plan | text | | |  
top\_query | text | | |  
application\_name | text | | |  
relations | text | | |  
cmd\_type | integer | | |  
cmd\_type\_text | text | | |  
elevel | integer | | |  
sqlcode | text | | |  
message | text | | |  
calls | bigint | | |  
total\_time | double precision | | |  
min\_time | double precision | | |  
max\_time | double precision | | |  
mean\_time | double precision | | |  
stddev\_time | double precision | | |  
rows | bigint | | |  
shared\_blks\_hit | bigint | | |  
shared\_blks\_read | bigint | | |  
shared\_blks\_dirtied | bigint | | |  
shared\_blks\_written | bigint | | |  
local\_blks\_hit | bigint | | |  
local\_blks\_read | bigint | | |  
local\_blks\_dirtied | bigint | | |  
local\_blks\_written | bigint | | |  
temp\_blks\_read | bigint | | |  
temp\_blks\_written | bigint | | |  
blk\_read\_time | double precision | | |  
blk\_write\_time | double precision | | |  
resp\_calls | text | | |  
cpu\_user\_time | double precision | | |  
cpu\_sys\_time | double precision | | |  
bucket\_done | boolean | | |

sds=#

 ![image](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/3X/0/8/087776074581cfed93cb27ac639b8c24dca98740.png)

**In the Postgresql.log file, I can see the full query.**

---

<div class="post-metadata">

**Author:** ![Roma\_Novikov](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/roma_novikov/32/1161_2.png) [@Roma\_Novikov](https://forums.percona.com/u/Roma_Novikov)\
**Post date:** [September 6, 2024, 12:43pm UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/19 "2024-09-06T12:43:00Z")

</div>

@Naresh9999, can you select \* from this table? do you have data inside it ?

---

<div class="post-metadata">

**Author:** ![Naresh9999](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/naresh9999/32/5568_2.png) [@Naresh9999](https://forums.percona.com/u/Naresh9999)\
**Post date:** [September 6, 2024, 12:53pm UTC](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879/20 "2024-09-06T12:53:49Z")

</div>

Yes @Roma_Novikov

I can see the data inside the below table.

select \* from pg\_stat\_monitor;

[Next page](https://forums.percona.com/t/postgresql-query-is-trimming-in-the-qan-dashboard/32879.md?page=2)
