您可以使用操作系统的 CPU 监视器(例如top
在 Linux 或 Windows 中的 ProcessExplorer)。
与数据库的每次连接都会在服务器上创建一个新进程。与连接相关的进程 id 报告在pid
系统视图的列中pg_stat_activity
。
使用该进程 ID,您可以监视该进程的 CPU 使用率,这实质上是您的查询的 CPU 使用率(当然,它正在运行时)
手册中的更多详细信息:http : //www.postgresql.org/docs/current/static/monitoring.html 和 Postgres Wiki:https : //wiki.postgresql.org/wiki/Performance_Analysis_Tools