PostgreSQL CPU 과다 사용 ( high CPU Usage )
Postgres 프로세스중에서 CPU가 높은 PID를 찾고, 해당 PID를 통해서 Postgres ID를 찾아,
실행중인 query문장을 찾는다.
>Postgres(포스트 그레스) Backend ID(datid)를 System 프로세스 ID와 일치하는 정보는 아래 쿼리 결과를 통해서 실행된 query를 살펴 볼 수 있다.
SELECT pid, datname, usename, query FROM pg_stat_activity
where pid='';
> 실행 결과 예제 ( 구version )
Column | Type | Description |
---|---|---|
datid | oid | OID of the database this backend is connected to |
datname | name | Name of the database this backend is connected to |
pid | integer | Process ID of this backend |
usesysid | oid | OID of the user logged into this backend |
usename | name | Name of the user logged into this backend |
application_name | text | Name of the application that is connected to this backend |
client_addr | inet | IP address of the client connected to this backend. If this field is null, it indicates either that the client is connected via a Unix socket on the server machine or that this is an internal process such as autovacuum. |
client_hostname | text | Host name of the connected client, as reported by a reverse DNS lookup of client_addr. This field will only be non-null for IP connections, and only when log_hostname is enabled. |
client_port | integer | TCP port number that the client is using for communication with this backend, or -1 if a Unix socket is used |
backend_start | timestamp with time zone | Time when this process was started, i.e., when the client connected to the server |
xact_start | timestamp with time zone | Time when this process' current transaction was started, or null if no transaction is active. If the current query is the first of its transaction, this column is equal to the query_start column. |
query_start | timestamp with time zone | Time when the currently active query was started, or if state is not active, when the last query was started |
state_change | timestamp with time zone | Time when the state was last changed |
waiting | boolean | True if this backend is currently waiting on a lock |
state | text | Current overall state of this backend. Possible values are:
|
query | text | Text of this backend's most recent query. If state is active this field shows the currently executing query. In all other states, it shows the last query that was executed. |
'DBMS, noSQL > PostgreSQL' 카테고리의 다른 글
Postgres 백업 및 복구 ( Backup & Restore with pgAdmin) (0) | 2017.07.21 |
---|---|
재구매, 연속 구매 (0) | 2017.04.12 |
Postgres , CSV를 Table로 import 하는 경우에 에러 발생 (0) | 2016.12.06 |
ERD 그리기, SQL Power Architect (0) | 2016.11.14 |
pgAdmin III, 연결 정보 리스트 추출(복사, 백업) (0) | 2016.10.17 |