Skip to content

Instantly share code, notes, and snippets.

before

cstore_test=# select product_group, count(*) from customer_reviews group by product_group;
 product_group |  count
---------------+---------
 DVD           |  121418
 Video         |  142235
 Music         |  300628
 Book          | 1198218
@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,