[英]PostgreSQL make CPU Usage 100%?
I'm using PostgreSQL
in my WPF Application
.我在我的
WPF Application
使用PostgreSQL
。
Sometime the PostgreSQL
makes CPU Usage up-to 100%.有时
PostgreSQL
使 CPU 使用率高达 100%。
I have encountered this issue many time, but I don't know the reason.我多次遇到这个问题,但我不知道原因。
The snapshot image in Task Manager is below任务管理器中的快照图像如下
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.请注意,发生此错误时,我杀死了我的应用程序 exe,然后等待 5 分钟,但任务管理器中的状态仍未改变。 CPU still 100%
CPU 仍然 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
.我正在使用
PostgreSQL 9.3
。
Anyone can show me the way to fix this.任何人都可以告诉我解决这个问题的方法。
Thank you :)谢谢 :)
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如果您仍然能够访问 postgres,我会考虑的一件事是您是否有任何可能被挂断的查询
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.这可能不是问题,但它至少会减少可能性的数量。
如果您不在数据库中使用索引,那么大多数情况下会出现问题,请对经常使用的字段使用索引,特别是如果您使用“order by”或聚合(例如 sum 和 count)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.