Skip to content

Instantly share code, notes, and snippets.

View lesovsky's full-sized avatar
😉
Don't stop

Lesovsky Alexey lesovsky

😉
Don't stop
  • Postgres Pro
  • Yekaterinburg, Russian Federation
View GitHub Profile
@zmts
zmts / tokens.md
Last active May 2, 2024 15:03
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@jberkus
jberkus / gist:6bbffae5ce10fb399d29
Last active January 13, 2018 06:55
Duplicate Index Query #2: Partial matches
-- check for containment
-- i.e. index A contains index B
-- and both share the same first column
-- but they are NOT identical
WITH index_cols_ord as (
SELECT attrelid, attnum, attname
FROM pg_attribute
JOIN pg_index ON indexrelid = attrelid
WHERE indkey[0] > 0
@ioguix
ioguix / btree_bloat.sql
Last active March 28, 2018 18:12
B-tree index bloat estimation
/* The bloat estimation queries moved to this respository:
* https://github.com/ioguix/pgsql-bloat-estimation
*/
@jberkus
jberkus / gist:6b1bcaf7724dfc2a54f3
Last active January 7, 2024 21:26
Finding Unused Indexes
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