Skip to content

Instantly share code, notes, and snippets.

View ahivert's full-sized avatar

Anthony Hivert ahivert

View GitHub Profile
@anvk
anvk / psql_useful_stat_queries.sql
Last active May 16, 2024 21:54
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@mgedmin
mgedmin / timeit-from-pdb-hack.md
Last active September 27, 2019 16:32
using timeit.timeit from pdb with access to a subset of local vars

= Problem =

timeit.timeit() doesn't let you pass local vars to the code to be timed.

= Solution =

(pdb) !import sys, timeit
(Pdb) !dv = (lambda sys=sys: (lambda **kw: setattr(sys.modules['__main__'], 'VARS', kw)))()
(Pdb) !tt = lambda s, sys=sys: sys.stdout.write('%.3g ms\n' % timeit.timeit(s, 'import sys; self = sys.modules["__main__"].SELF', number=10)/10.*1000)