Skip to content

Instantly share code, notes, and snippets.

Avatar

Nicolas Dufrane ndufrane

  • AIUR SCS
  • Belgium
View GitHub Profile
@ndufrane
ndufrane / delay_pg_restore_matviews
Created Sep 11, 2020 — 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))
QgsApplication.messageLog().messageReceived.connect(write_log_message)
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%'
You can’t perform that action at this time.