노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.

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 )



http://dba.stackexchange.com/questions/44084/troubleshooting-high-cpu-usage-from-postgres-and-postmaster-services






* pg_stat_activity 속성

One row per server process, showing information related to the current activity of that process, such as state and current query. See pg_stat_activity for details.
ColumnTypeDescription
datidoidOID of the database this backend is connected to
datnamenameName of the database this backend is connected to
pidintegerProcess ID of this backend
usesysidoidOID of the user logged into this backend
usenamenameName of the user logged into this backend
application_nametextName of the application that is connected to this backend
client_addrinetIP 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_hostnametextHost 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_portintegerTCP port number that the client is using for communication with this backend, or -1 if a Unix socket is used
backend_starttimestamp with time zoneTime when this process was started, i.e., when the client connected to the server
xact_starttimestamp with time zoneTime 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_starttimestamp with time zoneTime when the currently active query was started, or if state is not active, when the last query was started
state_changetimestamp with time zoneTime when the state was last changed
waitingbooleanTrue if this backend is currently waiting on a lock
statetextCurrent overall state of this backend. Possible values are:
  • active: The backend is executing a query.

  • idle: The backend is waiting for a new client command.

  • idle in transaction: The backend is in a transaction, but is not currently executing a query.

  • idle in transaction (aborted): This state is similar to idle in transaction, except one of the statements in the transaction caused an error.

  • fastpath function call: The backend is executing a fast-path function.

  • disabled: This state is reported if track_activities is disabled in this backend.

querytextText 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.


블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,