# Error in percona logs - pg\_stat\_monitor: pg: out of memory

**URL:** <https://forums.percona.com/t/error-in-percona-logs-pg-stat-monitor-pg-out-of-memory/39083>\
**Category:** PostgreSQL\
**Created:** [August 12, 2025, 6:01am UTC](https://forums.percona.com/t/error-in-percona-logs-pg-stat-monitor-pg-out-of-memory/39083 "2025-08-12T06:01:49Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ANDiv1976](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/andiv1976/32/20170_2.png) [@ANDiv1976](https://forums.percona.com/u/ANDiv1976)\
**Post date:** [November 21, 2025, 11:09am UTC](https://forums.percona.com/t/error-in-percona-logs-pg-stat-monitor-pg-out-of-memory/39083/3 "2025-11-21T11:09:38Z")

</div>

The problem of running out of memory is due to the fact that pg\_stat\_monitor does not collapse the same type of queries.

> [@Pg\_stat\_monitor 2.2 - Collapsing similar queries](https://forums.percona.com/t/pg-stat-monitor-2-2-collapsing-similar-queries/39763):
>
> Why doesn’t pg\_stat\_monitor 2.2 collapse such similar queries? Under high TPS, all buckets get filled with identical queries. As a result, it starts consuming more shared memory. It can collapse similar queries. In pg\_stat\_monitor, during just a few seconds of testing, there are 47,000 rows, with a limit of 20 buckets and pgsm\_max of 192MB. Is there a way to collapse similar queries? Which parameter in pg\_stat\_monitor is needed for this? I couldn’t find it in the documentation. …

---

_[View the full topic](https://forums.percona.com/t/error-in-percona-logs-pg-stat-monitor-pg-out-of-memory/39083)._
