Issues with the POSTGRESQL lock table

Source: Internet
Author: User
Tags postgresql

First, find out the statement

Select Wait.pid, wait.query as Wait_query, Wait.query_start as Wait_query_start, Wait.locktype, granted . pid as Waitfor_pid, Granted.relation, Granted.datname|| '. ' | | D.nspname | | '. ' | |C.relname as name, Granted.transactionid, Granted.virtualxid, Granted.usename, Granted.client_addr, GR Anted.query_start, Granted.queryfrom (select A.query, A.query_start, B.pid, b.re          Lation, B.transactionid, B.page, B.tuple, B.locktype, B.virtualxid from Pg_stat_activity A, pg_locks b where a.waiting= ' t 'and A.pid=B.pid and granted= ' F ') waitjoin (select B.pid, B.usename, B.client_addr, B.backend_start, B.query        _start, B.waiting, B.query, B.datname, A.relation, A.transactionid, A.page, A.tuple, A.locktype, A.virtualxid from Pg_locks A, pg_stat_activity b where a. PID=B.pid and a.granted= ' t ') Grantedon ((Wait.locktype= ' TransactionID 'and Granted.locktype= ' TransactionID 'and Wait.transactionid=Granted.transactionid) or (Wait.locktype= ' Relation 'and Granted.locktype= ' Relation 'and wait.relation=granted.relation) or (Wait.locktype= ' Virtualxid 'and Granted.locktype= ' Virtualxid 'and Wait.virtualxid=Granted.virtualxid) or (Wait.locktype= ' tuple 'and Granted.locktype= ' tuple 'and wait.relation=Granted.relation and Wait.page=Granted.page and Wait.tuple=granted.tuple)) Left join Pg_class con (c.relfilenode=wait.relation) LEFT join Pg_namespace Don (c.relnamespace=d.oid) Order Bygranted.query_start;

Second, kill the dependent SQL

Select Pg_terminate_backend (Process ID)

Issues with the POSTGRESQL lock table

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.