Skip to content

Instantly share code, notes, and snippets.

View abcfy2's full-sized avatar
😀
Focusing

Feng Yu abcfy2

😀
Focusing
View GitHub Profile
@NikolayS
NikolayS / queries_by_keyword.sql
Last active January 6, 2020 12:29
workload - pg_stat_statements
-- based on pg_stat_statements only
with data as (
select
lower(regexp_replace(query, '^\W*(\w+)\W+.*$', '\1')) word,
count(*) cnt,
sum(calls) calls,
sum(total_time) total_time
from pg_stat_statements
--where not query ~* '^\W*set\W+' -- uncomment this to exclude `SET ...`
group by 1