Skip to main content
Welcome, Guest. Please login.

Login with username, password and session length
8 Guests, 0 Users

Recent

Topic: MISC Queries (Read 18120 times) previous topic - next topic

MISC Queries

Compare two rows

Code: [Select]
SELECT T1.log_dt, T2.log_dt, EXTRACT(EPOCH FROM (T2.log_dt - T1.log_dt))
FROM power_data AS T1
INNER JOIN power_data  AS T2
USING ( node )
WHERE T1.log_dt > '2017-05-05 22:10:00'
AND T2.log_dt > '2017-05-05 22:10:00'
ORDER BY T1.id, T2.id
LIMIT 2

Re: MISC Queries

Reply #1
Show running queries (9.2)

Code: [Select]
SELECT pid, age(query_start, clock_timestamp()), usename, query 
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;

kill running query
Code: [Select]
SELECT pg_cancel_backend(procpid);

Kill idle query
Code: [Select]
SELECT pg_terminate_backend(procpid);