使用clickhouse MaterializedPostgreSQL同步数据,导致pg占用CPU资源高

暂时解决办法:

1、使用PG查询正在运行中的SQL

select datname,
       usename,
       client_addr,
       application_name,
       state,
       backend_start,
       xact_start,
       xact_stay,
       query_start,
       query_stay,
       replace(query, chr(10), ' ') as query
from
  (select pgsa.datname as datname,
          pgsa.usename as usename,
          pgsa.client_addr client_addr,
          pgsa.application_name as application_name,
          pgsa.state as state,
          pgsa.backend_start as backend_start,
          pgsa.xact_start as xact_start,
          extract(epoch
                  from (now() - pgsa.xact_start)) as xact_stay,
          pgsa.query_start as query_start,
          extract(epoch
                  from (now() - pgsa.query_start)) as query_stay,
          pgsa.query as query
   from pg_stat_activity as pgsa
   where pgsa.state != 'idle'
     and pgsa.state != 'idle in transaction'
     and pgsa.state != 'idle in transaction (aborted)') idleconnections
order by query_stay desc
limit 5;

2、使用PG查询正在运行中的SQL

使用clickhouse MaterializedPostgreSQL同步数据,导致pg占用CPU资源高_第1张图片
复制查询的SQL,查看具体连接的IP和执行SQL

3.解决方法:

我这边分析SQL是发现clickhouse的MaterializedPostgreSQL同步数据导致pg占用CPU资源过高,停止了具体的表数据同步,使用其他方式同步数据

你可能感兴趣的:(数据库,clickhouse,数据库,sql,postgresql,CPU占用资源过高)