P
P
pro100ckat2020-02-14 09:17:20
PostgreSQL
pro100ckat, 2020-02-14 09:17:20

What does the query result say? Or what conclusion can be drawn?

I am doing the following.

SELECT 
  query ________________actual_query____________________,
  client_addr client_ip,
  to_char(backend_start, 'YYYY-MM-DD HH:MM:SS') backend_start,
  to_char(query_start, 'YYYY-MM-DD HH:MM:SS') query_start,
  to_char(state_change, 'YYYY-MM-DD HH:MM:SS') state_change,
  wait_event_type wait,
  wait_event wait_event,
  STATE
FROM pg_stat_activity
order by backend_start

The database has a procedure that updates some data.
After the request, I see about 260 lines in a row of this kind.
5e463a8d1189a414560425.jpeg
What does state = active mean - the request has not yet completed and the update has not happened? What does wait = lock and wait_event = transaction_id mean?
I would be very grateful for any help!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Melkij, 2020-02-14
@melkij

What state = active says - the request has not yet completed

That the request is being fulfilled.
What does wait = lock and wait_event = transaction_id mean?

We are waiting for the result of another transaction.
which updates some data

transaction 1 has updated the row but has not yet completed.
transaction 2 wants to update the same row. But what data will she see? Those who have not yet confirmed transaction 1 - you can not. Suddenly transaction 1 will be rollback? Those who were before the arrival of transaction 1 - all the more impossible. Therefore, we wait until transaction 1 ends.
Find the beginning of this tail, for example , with such a request

K
ky0, 2020-02-14
@ky0

Obviously, you need to read the documentation for the relevant view .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question