简体   繁体   English

如何在pg_stat_activity中查看查询的模式?

[英]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.

相关问题 pg_stat_activity中的查询被截断 - Queries in pg_stat_activity are truncated pg_stat_activity 中的查询被截断了吗? - Queries in pg_stat_activity are truncated? 如何使用 pg_stat_activity? - How to use pg_stat_activity? pg_stat_activity - 如何查看正在运行的存储过程中的当前活动 - pg_stat_activity - how to see current activity inside a running stored procedure 在pg_stat_activity中具有“空闲”状态的持久“COMMIT”查询 - Long lasting 'COMMIT' queries with 'idle' state in pg_stat_activity 如何在PostgreSQL中显示来自pg_stat_activity的不收听*查询 - How to show unlisten * query from pg_stat_activity in postgresql 同时执行创建索引 statmt 并且由于超时错误而断开连接 session。但我确实在 pg_stat_activity 中看到,它正在运行 state - Executed create index concurrently statmt & it was disconnected session due to timeout error.but I do see in pg_stat_activity,it is in running state pg_stat_activity的奇怪输出 - Weird output of pg_stat_activity 使用 pg_stat_statements 加入 pg_stat_activity? - Join pg_stat_activity with pg_stat_statements? 如何在 Postgresql pg_stat_activity 中找到 ClientRead wait_event 的原因? - How to find cause of ClientRead wait_event in Postgresql pg_stat_activity?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM