OceanBase 查询某段时间内执行时间排名 TOP N 的请求

运行如下语句可以查询某段时间内执行时间排名 TOP N 的请求:

obclient>SELECT/*+ PARALLEL(15)*/ sql_id, elapsed_time , trace_id    
         FROM oceanbase.gv$sql_audit     
         WHERE   tenant_id = 1001 
         and IS_EXECUTOR_RPC = 0 
         and request_time > (time_to_usec(now()) - 10000000) 
         AND request_time < time_to_usec(now()) 
         ORDER BY elapsed_time DESC LIMIT 10;

+----------------------------------+--------------+-------------------------------+
| sql_id                           | elapsed_time | trace_id                      |
+----------------------------------+--------------+-------------------------------+
| CFA269275E3BB270408747C01F64D837 |        87381 | YB420AB75598-0005634FBED5C5E8 |
| 1979A5B4A27D5C3DBE08F80383FD6EB6 |        83465 | YB420AB74E56-0005634B4B87353B |
| 51248E6C3BB5EF1FC4E8E79CA685723E |        82767 | YB420AB74E56-0005634B4B82E7E1 |
| 249C40E669DFCCE80E3D11446272FA11 |        79919 | YB420A67E27C-00056349549A79D3 |
| BEFAD568C3858D2C2E35F01558CBEC06 |        77210 | YB420A67E4B1-00056345B0F2E97E |
| FB1A6A8BC4125C324A38F91B3808D364 |        75870 | YB420AB74E71-00056347074261E6 |
| 0343A519C0C5BF31C68CB68F63721990 |        75666 | YB420BB47107-00056346A5A631FB |
| B140BB0C671D9B8616FB048544F3B85B |        73902 | YB420A67E56B-00056342A5A4683E |
| 4F9B1D0A3822A3E0DF69DB11ABFBE0EA |        72963 | YB420BB47107-00056346A5AAC5F5 |
| 9963E8D252E6CBA72FBA45AC5790BA11 |        72354 | YB420A67E56B-00056342A5A66089 |
+----------------------------------+--------------+-------------------------------+

作者:terry,如若转载,请注明出处:https://www.web176.com/oceanbase/26122.html

(0)
打赏 支付宝 支付宝 微信 微信
terryterry
上一篇 2023年10月14日
下一篇 2023年10月14日

相关推荐

发表回复

登录后才能评论