0

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 :)

2
  • 1
    Are you running a query when this happens? Commented Jan 16, 2019 at 3:34
  • Yes, my app is running query frequently, so i think that at this time is not an exception. Commented Jan 16, 2019 at 3:56

2 Answers 2

6

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, I wil try and will let you know the result :)
1

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)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.