TTGroup
TTGroup

Reputation: 3703

PostgreSQL make CPU Usage 100%?

I'm using PostgreSQL in my WPF Application.

Sometime the PostgreSQL makes CPU Usage up-to 100%.

I have encountered this issue many time, but I don't know the reason.

The snapshot image in Task Manager is below

enter image description here

Note that, When this bug occurs, I kill my application exe, and wait for during 5 minutes after that, but the status in task manager still not change. CPU still 100%

I see that, it usually happens after Window Update. And I must restart the computer to by pass this.

I'm using PostgreSQL 9.3.

Anyone can show me the way to fix this.

Thank you :)

Upvotes: 0

Views: 13009

Answers (2)

Mahdi
Mahdi

Reputation: 835

most the time the problem appears if you do not use indexing in the database, use indexing for fields that are used frequently especially if you use "order by" or aggregation (such as sum and count)

Upvotes: 1

Mike
Mike

Reputation: 617

If you are able to still access postgres, one thing I'd look at is do you have any queries that might be hung up

SELECT
  pid,
  now() - pg_stat_activity.xact_start AS duration,
  query,
  state
FROM pg_stat_activity
WHERE (now() - pg_stat_activity.query_start) > interval '4 minutes';

if there is indeed a query that has been alive longer than it should be, you can delete like so:

SELECT pg_cancel_backend(<pid>);

This might not be the problem, but it will at least reduce the number of possibilities.

Upvotes: 6

Related Questions