Skip to content

Instantly share code, notes, and snippets.

@ng-pe
ng-pe / postgresql_pg_stat_activity_with_tempfiles.sql
Last active January 29, 2021 13:51
postgresql "pg_stat_activity" with temporary files information
-- View pg_stat_activity with temporary files informations (file list and total file size)
-- version 0.3
SELECT
pg_stat_activity.pid AS pid,
CASE WHEN LENGTH(pg_stat_activity.datname) > 16
THEN SUBSTRING(pg_stat_activity.datname FROM 0 FOR 6)||'...'||SUBSTRING(pg_stat_activity.datname FROM '........$')
ELSE pg_stat_activity.datname
END
AS database,
@ng-pe
ng-pe / tarWithProgress.sh
Last active June 25, 2019 06:02
Tar with percent progress
#!/bin/bash
# TAR with progress demo
# in this Gist "demo.data" is file to archive
total=`du demo.data -B10K --apparent-size | cut -f1`
export total=$total
BZIP2="-2 -s" tar --checkpoint=1 --checkpoint-action=exec=' printf "%03d/100\r" $((100*$TAR_CHECKPOINT/$total)) ' -cjvf demo.tar.bz2 demo.data
# output demo :
#./demoscript.sh