Skip to content

Instantly share code, notes, and snippets.

@VladimirPal
VladimirPal / gist:d703d5715966c641dd38
Created May 19, 2015 08:12
alembic default boolean
op.add_column('projects', sa.Column('is_closed', sa.Boolean(), server_default=sa.schema.DefaultClause("0"), nullable=False))
@ruckus
ruckus / statistics.sql
Created June 5, 2013 23:26
Postgres statistics queries
** Find commmonly accessed tables and their use of indexes:
SELECT relname,seq_tup_read,idx_tup_fetch,cast(idx_tup_fetch AS numeric) / (idx_tup_fetch + seq_tup_read) AS idx_tup_pct FROM pg_stat_user_tables WHERE (idx_tup_fetch + seq_tup_read)>0 ORDER BY idx_tup_pct;
Returns output like:
relname | seq_tup_read | idx_tup_fetch | idx_tup_pct
----------------------+--------------+---------------+------------------------
schema_migrations | 817 | 0 | 0.00000000000000000000
user_device_photos | 349 | 0 | 0.00000000000000000000