Skip to content

Instantly share code, notes, and snippets.

View ndufrane's full-sized avatar

Nicolas Dufrane ndufrane

  • Belgium
View GitHub Profile
ndufrane / delay_pg_restore_matviews
Created September 11, 2020 14:01 — forked from kmatt/delay_pg_restore_matviews
Delay materialized view refresh during pg_restore
View delay_pg_restore_matviews
pg_dump database -Fc backup.dump
pg_restore -l backup.dump | sed '/MATERIALIZED VIEW DATA/d' > restore.lst
pg_restore -L restore.lst -d database backup.dump
pg_restore -l backup.dump | grep 'MATERIALIZED VIEW DATA' > refresh.lst
pg_restore -L refresh.lst -d database backup.dump
View gist:a625dc823ee77b0f44753fbfbf242d56
filename = 'c:\\Users\\ndufrane\qgis.log'
def write_log_message(message, tag, level):
with open(filename, 'a') as logfile:
logfile.write('{tag}({level}): {message}'.format(tag=tag, level=level, message=message))
ndufrane / postgres_queries_and_commands.sql
Created April 28, 2017 12:02 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
View postgres_queries_and_commands.sql
-- show running queries (pre 9.2)
SELECT procpid, age(query_start, clock_timestamp()), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(query_start, clock_timestamp()), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'