본문 바로가기

Database/Postgresql

postgresql/greenplum uptime을 to_char 함수로 보기편하게 변경하기

728x90
반응형

 

현재 서비스중인 postgresql/greenplum 을 현재 구동되었는지 확인할때 사용하는 개념이 uptime 이고 함수는 pg_postmaster_start_time() 를 이용하면 쉽게 확인할 수 있다.

 

-- postgresql/greenplum start_time
select pg_postmaster_start_time()

-- postgresql/greenplum uptime
select current_timestamp - pg_postmaster_start_time() as uptime

 

postgresql/greenplum uptime

 

하지만 분초단위의 데이터가 표시되어 보기가 불편하다. to_char 함수를 이용하여 보기편하게 변경해보자.

 

-- postgresql/greenplum uptime - to_char 를 이용
select to_char(current_timestamp - pg_postmaster_start_time(), 'DD"d" HH24"h" MI"m"') as uptime

 

postgresql/greenplum to_char를 이용한 uptime 표시

해당 postgresql 의 db 구동시간은 82일 22시간이 지나고 있는 것을 확인 할 수 있다.

 

<에필로그>

  • postgresql/greenplum 을 사용하다보면 쿼리패닉이슈가 간혹 발생할 경우가 있는데 해당이슈는 db가 자체적으로 재구동 방식으로 해결한다.
  • 새벽에 쿼리패닉이슈가 발생하면 DB담당자(예:DBA)가 아침에 출근 후 해당사항을 지나칠 수가 있으므로 uptime 을 확인하는 업무는 간단해 보일지만 중요한 사항이다.

 

 

728x90
반응형