SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE pid <> pg_backend_pid()
AND state = 'idle'
AND state_change < current_timestamp - INTERVAL '5' MINUTE;
given a database named db:
SELECT pg_terminate_backend(pid)
FROM pg_stat_activity
WHERE datname='db'
AND state = 'idle in transaction'
SELECT
table_name,
pg_size_pretty(table_size) AS table_size,
pg_size_pretty(indexes_size) AS indexes_size,
pg_size_pretty(total_size) AS total_size
FROM (
SELECT
table_name,
pg_table_size(table_name) AS table_size,
CREATE VIEW blocking_processes AS
SELECT
pg_locks2.pid as blocking_pid,
ka.usename as blocking_user,
ka.query as blocking_query,
pg_locks1.pid as blocked_pid,
psa.usename as blocked_user,
psa.query as blocked_query,
to_char(age(now(), psa.query_start),'HH24h:MIm:SSs') as age
http://eloquentjavascript.net/index.html | |
http://eloquentjavascript.net/00_intro.html | |
http://eloquentjavascript.net/01_values.html | |
http://eloquentjavascript.net/02_program_structure.html | |
http://eloquentjavascript.net/03_functions.html | |
http://eloquentjavascript.net/04_data.html | |
http://eloquentjavascript.net/05_higher_order.html | |
http://eloquentjavascript.net/06_object.html | |
http://eloquentjavascript.net/07_elife.html | |
http://eloquentjavascript.net/08_error.html |
About twenty years ago Jobs and Wozniak, the founders of Apple, came up with the very strange idea of selling information processing machines for use in the home. The business took off, and its founders made a lot of money and received the credit they deserved for being daring visionaries. But around the same time, Bill Gates and Paul Allen came up with an idea even stranger and more fantastical: selling computer operating systems. This was much weirder than the idea of Jobs and Wozniak. A computer at least had some sort of physical reality to it. It came in a box, you could open it up and plug it in and watch lights blink. An operating system had no tangible incarnation at all. It arrived on a disk, of course, but the disk was, in effect, nothing more than the box that the OS came in. The product itself was a very long string of ones and zeroes that, when properly installed and coddled, gave you the ability to manipulate other very long strings of ones and zeroes. Even those few who actually understood what