Skip to content

Instantly share code, notes, and snippets.

WITH table_scans as (
SELECT relid,
tables.idx_scan + tables.seq_scan as all_scans,
( tables.n_tup_ins + tables.n_tup_upd + tables.n_tup_del ) as writes,
pg_relation_size(relid) as table_size
FROM pg_stat_user_tables as tables
),
all_writes as (
SELECT sum(writes) as total_writes
FROM table_scans
@mlissner
mlissner / decorators.py
Last active May 6, 2021 15:05
A retry decorator to catch specific exceptions and retry the code, with exponential backoff
import time
from functools import wraps
from typing import Callable, Type
def retry(
ExceptionToCheck: Type[Exception],
tries: int = 4,
delay: float = 3,
backoff: float = 2,