Skip to content

Instantly share code, notes, and snippets.

View NikolayS's full-sized avatar
🐘
Need help with Postgres? Let me know!

Nik Samokhvalov NikolayS

🐘
Need help with Postgres? Let me know!
View GitHub Profile
@NikolayS
NikolayS / flamegraph-hwwatch.svg
Last active March 20, 2026 02:59
USDT wait event tracepoint flamegraphs - pgbench c64 comparison
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@NikolayS
NikolayS / flamegraph_full.svg
Created March 18, 2026 03:19
rpg non_ai_paths benchmark flamegraphs (macOS/aarch64)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@NikolayS
NikolayS / VSDD.md
Created March 1, 2026 03:45 — forked from dollspace-gay/VSDD.md
Verified Spec-Driven Development

Verified Spec-Driven Development (VSDD)

The Fusion: VDD × TDD × SDD for AI-Native Engineering

Overview

Verified Spec-Driven Development (VSDD) is a unified software engineering methodology that fuses three proven paradigms into a single AI-orchestrated pipeline:

  • Spec-Driven Development (SDD): Define the contract before writing a single line of implementation. Specs are the source of truth.
  • Test-Driven Development (TDD): Tests are written before code. Red → Green → Refactor. No code exists without a failing test that demanded it.
@NikolayS
NikolayS / abstracts_writings.md
Last active June 17, 2025 07:18
Как написать хорошие тезисы для доклада на конференции

Рекомендации для докладов типа Case Study (компания/проект делится своим опытом)

Недостаточно просто описать задачу в тезисах. Довольно часто бывает так, что заинтересованные слушатели могут это сделать не хуже докладчика. Хорошие же тезисы отличает конкретика: конкретные названия, конкретные числовые показатели (последнее особенно важно для Highload++).

Главное — приоткрыть суть вашего доклада, оставаясь при этом в рамках сжатых тезисов.

И это не так сложно. При подготовке доклада и его тезисов нужно сделать всего лишь три шага.

@NikolayS
NikolayS / gist:cb028d6c49e6f9e3ea8e1944452d9ff5
Last active February 13, 2025 15:20
PostgreSQL: move all objects from one tablespace to default one
-- The following code will generate a set of ALTER queries
-- to move tables and indexes from one tablespace to another.
-- WARNING: Running such ALTERs in production means huge stress for DB.
-- Use pg_repack with "-s" option (http://reorg.github.io/pg_repack/)
-- TODO: generate pg_repack call, smth like:
-- pg_repack [connection creds] -s TABLESPACENAME \
-- -t tbl1 \
-- ...
-- -i idx1 \
@NikolayS
NikolayS / file_fdw__csv.sql
Last active September 29, 2024 13:50
Postgres: CSV file as a table using FDW
-- Installs "file_fdw" extension and creates foreign table to work with data from CSV file.
-- See also the comment below which helps to automate the process for Google Spreadsheets
-- Another option would be using Multicorn for Google Spreadsheets, but it requires additional steps
-- (see https://wiki.postgresql.org/wiki/Foreign_data_wrappers).
create extension file_fdw;
create server "import" foreign data wrapper file_fdw;
create foreign table "table1" (
col1 text,
@NikolayS
NikolayS / pg_graph
Last active December 21, 2023 08:32 — forked from akorotkov/pg_graph
Draw psql output as iTerm2 v3 inline graph using matplotlib
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Draw psql output as iTerm2 v3 inline graph using matplotlib
# Author: Alexander Korotkov <aekorotkov@gmail.com>
# with a few edits by nik@postgres.ai to support Python3
import sys
import re
import warnings
import matplotlib
@NikolayS
NikolayS / 00_slowest_queries_full.sql
Last active November 28, 2023 19:06
Useful Postgres Queries
-- In pg_stat_statements, there is a problem: sometimes (quite often), it registers the same query twice (or even more).
-- It's easy to check in your DB:
--
-- with heh as (
-- select userid, dbid, query, count(*), array_agg(queryid) queryids
-- from pg_stat_statements group by 1, 2, 3 having count(*) > 1
-- ) select left(query, 85) || '...', userid, dbid, count, queryids from heh;
--
-- This query gives you "full picture", aggregating stats for each query-database-username ternary
@NikolayS
NikolayS / 1.md
Created September 26, 2023 15:28
EXPLAIN ANALYZE or EXPLAIN (ANALYZE, BUFFERS)?

When analyzing Postgres query execution plans, it is recommended using the BUFFERS option:

explain (analyze, buffers) <query>;

Example:

test=# explain (analyze, buffers) select * from t1 where num > 10000 order by num limit 1000;
                                                                QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------
@NikolayS
NikolayS / gist:1bbc624dfc088be6f15c
Last active July 23, 2023 16:51
Oracle's attempt to protect its place on the Russian market of database systems (RU + EN)
Источник: http://img11.postila.ru/data/34/fb/11/82/34fb118246ebb0b6a7f2dc6e7685f5ff62c0d9cff90876b283f3ecb521444775.jpg
(документ, упоминаемый в статье Ведомостей http://www.vedomosti.ru/technology/articles/2016/03/17/633926-importnii-soft-zamenit)
Почему PostgreSQL не является аналогом СУБД Oracle
С 1 января 2016 года в России вступает в действие постановление РФ "Об установлении запрета на допуск
Программного обеспечения, происходящего из иностранных государств, для целей осуществления закупок для обеспечения
государственных и муниципальных нужд". В соответствии с этим постановлением 1 января 2016 года формируется
реестр российского программного обеспечения (ПО)и госорганизации могут покупать ПО иностранных фирм