当前位置: 首页 > news >正文

【GBase 8c V5_3.0.0 分布式数据库常用几个SQL】

1.检查应用连接数

以管理员用户 gbase,登录数据库主节点。
接数据库,并执行如下 SQL 语句查看连接数。

SELECT count(*) FROM (SELECT pg_stat_get_backend_idset() AS backendid) AS s;

image.png

2.查看空闲连接

查看空闲(state 字段为”idle”)且长时间没有更新过的连接信息,使用如下命令。

SELECT * FROM pg_stat_activity where state='idle' order by state_change;

image.png

3.查看慢SQL

查看数据库实例中慢SQL语句执行信息,语法格式:

select * from dbe_perf.get_global_slow_sql_by_timestamp(start_timestamp, end_timestamp);

例如

select * from DBE_PERF.get_global_full_sql_by_timestamp('2024-08-30 09:25:22', '2024-08-30 23:54:41');

image.png

4.查看历史SQL

查看当前主节点SQL语句执行信息

 select * from statement_history;

表的结构为

postgres=# \d statement_historyUnlogged table "pg_catalog.statement_history"Column        |           Type           | Modifiers 
----------------------+--------------------------+-----------db_name              | name                     | schema_name          | name                     | origin_node          | integer                  | user_name            | name                     | application_name     | text                     | client_addr          | text                     | client_port          | integer                  | unique_query_id      | bigint                   | debug_query_id       | bigint                   | query                | text                     | start_time           | timestamp with time zone | finish_time          | timestamp with time zone | slow_sql_threshold   | bigint                   | transaction_id       | bigint                   | thread_id            | bigint                   | session_id           | bigint                   | n_soft_parse         | bigint                   | n_hard_parse         | bigint                   | query_plan           | text                     | n_returned_rows      | bigint                   | n_tuples_fetched     | bigint                   | n_tuples_returned    | bigint                   | n_tuples_inserted    | bigint                   | n_tuples_updated     | bigint                   | n_tuples_deleted     | bigint                   | n_blocks_fetched     | bigint                   | n_blocks_hit         | bigint                   | db_time              | bigint                   | cpu_time             | bigint                   | execution_time       | bigint                   | parse_time           | bigint                   | plan_time            | bigint                   | rewrite_time         | bigint                   | pl_execution_time    | bigint                   | pl_compilation_time  | bigint                   | data_io_time         | bigint                   | net_send_info        | text                     | net_recv_info        | text                     | net_stream_send_info | text                     | net_stream_recv_info | text                     | lock_count           | bigint                   | lock_time            | bigint                   | lock_wait_count      | bigint                   | lock_wait_time       | bigint                   | lock_max_count       | bigint                   | lwlock_count         | bigint                   | lwlock_wait_count    | bigint                   | lwlock_time          | bigint                   | lwlock_wait_time     | bigint                   | details              | bytea                    | is_slow_sql          | boolean                  | trace_id             | text                     | 
Indexes:"statement_history_time_idx" btree (start_time, is_slow_sql) TABLESPACE pg_default
Replica Identity: NOTHING

备库

select * from dbe_perf.standby_statement_history(true, '2024-08-30 09:25:22', '2024-08-30 23:54:41');

5.数据库实例中SQL语句执行信息

查看数据库实例中SQL语句执行信息,语法格式:

select * from dbe_perf.get_global_full_sql_by_timestamp('2024-08-30 09:25:22', '2024-08-30 23:54:41');

image.png

6.执行加载配置文件命令

select pg_reload_cong();
http://www.lryc.cn/news/438353.html

相关文章:

  • grep,wc命令
  • NLP-文本分类文献阅读-前置基础-词汇解释-通俗易懂-9月份-学习总结
  • Conda安装和使用(ubuntu)
  • JavaEE:文件操作
  • Python | 练习作业 2
  • C语言-整数和浮点数在内存中的存储-详解-上
  • 图论篇--代码随想录算法训练营第六十一天打卡| Floyd 算法,A*算法
  • CMake构建学习笔记16-使用VS进行CMake项目的开发
  • 数据结构中线性表的定义和特点
  • 【PyTorch单点知识】PyTorch中的自动混合精度(AMP)模块详解
  • 数据结构 --- 哈希表
  • Linux相关:在阿里云下载centos系统镜像
  • 24. 线模型对象
  • EasyExcel 快速入门
  • Sparse4D v1
  • 速盾:你知道高防 IP 和高防 CDN 的区别吗?
  • HTML和CSS网页制作成品
  • Ai+若依(集成easyexcel实现excel表格增强)
  • 钻机、塔吊等大型工程设备,如何远程维护、实时采集运行数据?
  • 【AutoX.js】选择器 UiSelector - 查找包名
  • ERP进销存多仓库管理系统源码 带完整的安装代码包以及搭建部署教程
  • 数据清洗-缺失值填充-对XGBoost参数优化填充
  • Qt_按钮类控件
  • union 的定义和基本结构以及用途
  • 混合整数规划及其MATLAB实现
  • 【数据结构】6——图1,概念
  • 技术周总结 09.09~09.15周日(C# WinForm WPF)
  • 4K投影仪选购全攻略:全玻璃镜头的当贝F6,画面细节纤毫毕现
  • 除了字符串前导的*号之外,将串中其它*号全部删除
  • SpringBoot开发——使用@Slf4j注解实现日志输出