Skip to content

Instantly share code, notes, and snippets.

View neilpw's full-sized avatar

Neil Banerjee neilpw

  • Oakland, CA
View GitHub Profile
@neilpw
neilpw / export-emails.sql
Created April 25, 2020 19:23
Export email activity
-- Generates a CSV export of all user-logged activities.
-- Adjust Company ID and activity time as needed.
-- If running against a follower DB, selecting into a temporary
-- table won't work. Instead, remove all the newlines to fit
-- the entire query into one line, and use it directly in the
-- \copy command, e.g.:
--
-- \copy (WITH entity_types ... SELECT * FROM tmp_results_1) TO 'filename.csv' WITH CSV HEADER
@neilpw
neilpw / pg-locks-queries.sql
Created April 16, 2020 20:26
PG open locks and queries
SELECT
pg_locks.locktype,
pg_locks.mode,
pg_locks.granted,
pg_locks.pid,
pg_class.relname,
now() - pg_stat_activity.query_start "query_age",
now() - pg_stat_activity.xact_start "xact_age",
pg_stat_activity.query
FROM