[英]How can I see schema for queries in pg_stat_activity?
I am trying to sort out some app performance issues with slow queries. 我试图通过慢查询来解决一些应用程序性能问题。 We are using Postgresql 9.2.
我们正在使用Postgresql 9.2。 I can see the queries in progress easily:
我可以轻松地看到正在进行的查询:
postgres=# select now() - query_start, query from pg_stat_activity where state <> 'idle';
00:00:01.535388 | select bla from product where ...
I need to know what schema the tables listed in the query are in. How can I see which "product" table is being queried given that there are hundreds of them in different schemas in the same database. 我需要知道查询中列出的表是什么模式。如果在同一个数据库中的不同模式中有数百个表,我怎样才能看到正在查询的“产品”表。
pg_stat_activity view calls pg_stat_get_activity(pid int) internal function. pg_stat_activity视图调用pg_stat_get_activity(pid int)内部函数。 You have no chances to change query text in result.
您没有机会在结果中更改查询文本。 There is only one solution for now - call your queries with schema names:
现在只有一个解决方案 - 使用模式名称调用查询:
select bla from myschema.product where ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.