zoukankan      html  css  js  c++  java
  • gp日志查看

    笔记:之前登录master节点看pg_log目录下的文件,后面每次这样看感觉挺不方便的,查了一下文档

    select ma.logtime at time zone 'CST' as logtime,ma.loguser,ma.logpid,ma.loghost,ma.logstate,ma.logmessage,ma.logdetail from gp_toolkit.gp_log_database ma order by logtime desc limit 200;

    这个就是查的pg_log下的日志文件,只是是外部表形式,所以性能有一些差,只要定时切割pg_log下面的文件就行,还有一个视图 gp_toolkit.gp_log_system, 它与 gp_toolkit.gp_log_database 区别是一个是all,一个是current_database。

    表空间间隙查看方法(膨胀):

    select * from gp_toolkit.gp_log_database;

    表空间间隙收缩方法:

    #!/bin/bash
    DBNAME="<database_name>"
    SYSTABLES="' pg_catalog.' || relname || ';' from pg_class a, pg_namespace b 
    where a.relnamespace=b.oid and b.nspname='pg_catalog' and a.relkind='r'"
    psql -tc "SELECT 'VACUUM' || $SYSTABLES" $DBNAME | psql -a $DBNAME
    reindexdb -s -d $DBNAME
    analyzedb -s pg_catalog -d $DBNAME

    查锁情况:

    SELECT least(query_start,xact_start) + '8 hour' start_time
                 ,pg_locks.pid
                 , pg_database.datname
                 , pg_stat_activity.usename
                 , locktype
                 , mode
                 , pg_stat_activity.application_name
                 , state
                 , CASE WHEN granted='f' THEN 'wait_lock' WHEN granted='t' THEN 'get_lock' END lock_satus
                 , pg_stat_activity.query
                 , count(*)::float
              FROM pg_locks
              JOIN pg_database ON pg_locks.database=pg_database.oid
              JOIN pg_stat_activity on pg_locks.pid=pg_stat_activity.pid
            WHERE NOT pg_locks.pid=pg_backend_pid()
            AND pg_stat_activity.application_name<>'pg_statsinfod'
            GROUP BY pg_locks.pid, pg_database.datname,pg_stat_activity.usename, locktype, mode,
            pg_stat_activity.application_name, state , lock_satus ,pg_stat_activity.query, start_time
            ORDER BY 2 desc;
  • 相关阅读:
    一个小程序的经验总结
    my favorite computer publishers
    关于在天涯看小说
    书店
    Server 2003&Windows 7&Server 2008 R2&Visual Studio&MSDN: my personal best practice
    Google搜索:基本语法
    【我喜欢的一篇文章】Fire And Motion
    Windbg学习笔记(1)
    如何清除Help Viewer 2.0之Filter Contents中的列表内容
    5年了,难道我真的不适合做一个程序员吗,请告诉我我该怎么做?
  • 原文地址:https://www.cnblogs.com/5sdba-notes/p/14128324.html
Copyright © 2011-2022 走看看