# PostgreSQL High CPU utilization Issue while doing load test

**URL:** <https://forums.percona.com/t/postgresql-high-cpu-utilization-issue-while-doing-load-test/32938>\
**Category:** PostgreSQL\
**Created:** [September 5, 2024, 3:16pm UTC](https://forums.percona.com/t/postgresql-high-cpu-utilization-issue-while-doing-load-test/32938 "2024-09-05T15:16:18Z")\
**Posts on this page:** 5\
**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 5, 2024, 3:16pm UTC](https://forums.percona.com/t/postgresql-high-cpu-utilization-issue-while-doing-load-test/32938/1 "2024-09-05T15:16:18Z")

</div>

Hi All,

We are performing a load test (Java application); we don’t see any high CPU queries or slow queries, but Postgres processes (around 20 processes) are simultaneously taking 100% CPU. We are unable to figure out the issue, how to find a solution, why, and which queries or any other are taking that many CPU’s.

# Here are the env details.

PostgreSQL DB Version: 12  
PostgreSQL DB Server CPU’s: 6  
PostgreSQL DB Server RAM: 8 GB  
Number of API’s: 6  
Per API parallel threads: 10

---

<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 5, 2024, 5:00pm UTC](https://forums.percona.com/t/postgresql-high-cpu-utilization-issue-while-doing-load-test/32938/2 "2024-09-05T17:00:50Z")

</div>

Run these two queries while it’s under load  
select \* from pg\_stat\_activity  
select \* from pg\_locks

Make certain pg\_stat\_statements is installed and query the view.

And finally, log all postgres messages. Make certain you’ve updated the settings that you can adequate 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 6, 2024, 6:24am UTC](https://forums.percona.com/t/postgresql-high-cpu-utilization-issue-while-doing-load-test/32938/3 "2024-09-06T06:24:00Z")

</div>

Hi @Robert_Bernier

I have installed the pg\_stat\_statements using PMM, and we are monitoring the queries. But I could not find any queries that are causing high CPU usage.

I did not find any locking queries as well.

---

<div class="post-metadata">

**Author:** ![Shivam\_Dhapatkar](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/shivam_dhapatkar/32/8774_2.png) [@Shivam\_Dhapatkar](https://forums.percona.com/u/Shivam_Dhapatkar)\
**Post date:** [October 17, 2024, 5:17pm UTC](https://forums.percona.com/t/postgresql-high-cpu-utilization-issue-while-doing-load-test/32938/4 "2024-10-17T17:17:45Z")

</div>

Hello Naresh,  
You can identify the queries that are causing high CPU usage by using the pg\_stat\_activity view. Take the Process IDs that are consuming high CPU at the operating system level and query the pg\_stat\_activity view as shown below:

```auto
select * from pg_stat_activity where pid='<process ID>';

```

Thanks.

---

<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:** [October 18, 2024, 8:28am UTC](https://forums.percona.com/t/postgresql-high-cpu-utilization-issue-while-doing-load-test/32938/5 "2024-10-18T08:28:12Z")

</div>

Thanks @Shivam_Dhapatkar

I will check and let you know.
