在 Informix 上查找长时间运行的查询?

发布于 2024-07-04 03:45:51 字数 69 浏览 7 评论 0原文

如何找出 Informix 数据库服务器上长时间运行的查询是什么? 我有一个查询正在耗尽 CPU,并且想找出该查询是什么。

How can you find out what are the long running queries are on Informix database server? I have a query that is using up the CPU and want to find out what the query is.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

维持三分热 2024-07-11 03:45:51

如果查询当前正在运行,请观察 onstat -g act -r 1 输出并查找 rstcb 不为 0 的

Running threads:
 tid     tcb             rstcb            prty status                vp-class      name
 106     c0000000d4860950 0                2    running               107soc        soctcppoll
 107     c0000000d4881950 0                2    running               108soc        soctcppoll
 564457  c0000000d7f28250 c0000000d7afcf20 2    running                 1cpu        CDRD_10

项目例如,第三行是当前正在运行的内容。 如果您有多行具有非零 rstcb 值,则请注意寻找始终或几乎始终存在的行。 这很可能就是您正在寻找的会议。

c0000000d7afcf20 是我们在此示例中感兴趣的地址。

使用 onstat -u | grep c0000000d7afcf20 查找会话

c0000000d7afcf20 Y--P--- 22887    informix -        c0000000d5b0abd0 0    5     14060    3811

这将为您提供会话 ID,在我们的示例中为 22887。 使用onstat -g ses 22887
列出有关该会话的信息。 在我的示例中,它是一个系统会话,因此 onstat -g ses 输出中看不到任何内容。

If the query is currently running watch the onstat -g act -r 1 output and look for items with an rstcb that is not 0

Running threads:
 tid     tcb             rstcb            prty status                vp-class      name
 106     c0000000d4860950 0                2    running               107soc        soctcppoll
 107     c0000000d4881950 0                2    running               108soc        soctcppoll
 564457  c0000000d7f28250 c0000000d7afcf20 2    running                 1cpu        CDRD_10

In this example the third row is what is currently running. If you have multiple rows with non-zero rstcb values then watch for a bit looking for the one that is always or almost always there. That is most likely the session that your looking for.

c0000000d7afcf20 is the address that we're interested in for this example.

Use onstat -u | grep c0000000d7afcf20 to find the session

c0000000d7afcf20 Y--P--- 22887    informix -        c0000000d5b0abd0 0    5     14060    3811

This gives you the session id which in our example is 22887. Use onstat -g ses 22887
to list info about that session. In my example it's a system session so there's nothing to see in the onstat -g ses output.

玩物 2024-07-11 03:45:51

好吧,我花了一些时间才弄清楚如何连接到 sysmaster。 JDBC 连接字符串为:

jdbc:informix-sqli://dbserver.local:1526/sysmaster:INFORMIXSERVER=mydatabase

其中端口号与连接到实际数据库时的端口号相同。 也就是说,如果您的连接字符串是:

jdbc:informix-sqli://database:1541/crm:INFORMIXSERVER=crmlive

那么 sysmaster 连接字符串为:

jdbc:informix-sqli://database:1541/sysmaster:INFORMIXSERVER=crmlive

还找到 此 wiki 页面,其中包含许多用于操作 sysmaster 表的 SQL 查询。

Okay it took me a bit to work out how to connect to sysmaster. The JDBC connection string is:

jdbc:informix-sqli://dbserver.local:1526/sysmaster:INFORMIXSERVER=mydatabase

Where the port number is the same as when you are connecting to the actual database. That is if your connection string is:

jdbc:informix-sqli://database:1541/crm:INFORMIXSERVER=crmlive

Then the sysmaster connection string is:

jdbc:informix-sqli://database:1541/sysmaster:INFORMIXSERVER=crmlive

Also found this wiki page that contains a number of SQL queries for operating on the sysmaster tables.

心安伴我暖 2024-07-11 03:45:51
SELECT ELAPSED_TIME_MIN,SUBSTR(AUTHID,1,10) AS AUTH_ID, 
AGENT_ID, APPL_STATUS,SUBSTR(STMT_TEXT,1,20) AS SQL_TEXT
FROM SYSIBMADM.LONG_RUNNING_SQL
WHERE ELAPSED_TIME_MIN > 0
ORDER BY ELAPSED_TIME_MIN DESC

信用:用于查看长时间运行查询的 SQL

SELECT ELAPSED_TIME_MIN,SUBSTR(AUTHID,1,10) AS AUTH_ID, 
AGENT_ID, APPL_STATUS,SUBSTR(STMT_TEXT,1,20) AS SQL_TEXT
FROM SYSIBMADM.LONG_RUNNING_SQL
WHERE ELAPSED_TIME_MIN > 0
ORDER BY ELAPSED_TIME_MIN DESC

Credit: SQL to View Long Running Queries

影子是时光的心 2024-07-11 03:45:51

这是因为建议的答案适用于 DB2,而不是 Informix。

sysmaster 数据库(Informix 共享内存的虚拟关系数据库)可能包含您要查找的信息。 这些页面可能会帮助您入门:

That's because the suggested answer is for DB2, not Informix.

The sysmaster database (a virtual relational database of Informix shared memory) will probably contain the information you seek. These pages might help you get started:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文