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 / samogrow-landing-redesign-standalone.html
Created August 18, 2026 15:29
samogrow landing redesign canvas — public mobile viewer
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>samogrow Landing Redesign — design proposal</title>
<meta name="description" content="Five artboards proposing a two-voice redesign of the samogrow.dev landing page: warm field-guide editorial paired with a precise console register.">
<style>
:root{--paper:#f2ede0;--card:#f7f3e8;--ink:#1c2216;--ink-soft:#4a5340;--ink-faint:#636b59;
--line:#cdc4ac;--leaf:#35722f;--leaf-dk:#2b5c26;
@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 / 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 / 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 / at_time_zone.sql
Last active September 4, 2019 19:27
SQL (Postgres) and timestamps 🤦‍
set timezone to 'EST';
with data(t) as (
select timestamp '2019-01-01 12:00'
)
select
t,
pg_typeof(t),
t at time zone 'UTC',
pg_typeof(t at time zone 'UTC')
@NikolayS
NikolayS / lets_reuse_same_space.md
Last active February 18, 2019 03:28
Why index maintenance (e.g. with pg_repack) is an inevitable thing?
test=# \timing
Timing is on.
test=#
test=#
test=# create table t1 as select i from generate_series(1, 1000000) _(i);
SELECT 1000000
Time: 660.804 ms
test=# create unique index i_t1 on t1(i);
CREATE INDEX
@NikolayS
NikolayS / dba_pgss.sql
Last active November 19, 2021 16:55
Simple pg_stat_statements snapshots
create schema dba;
-- on GCP's Cloud SQL for Postgres, if we work with more than one DB user,
-- we have a problem – some queries are not visible (`<insufficient privilege>`),
-- so we need to use a workaround
create or replace function dba.pgss_snapshot() returns setof pg_stat_statements as $$
declare
rec pg_stat_statements;
_role text;
begin
@NikolayS
NikolayS / queries_by_keyword.sql
Last active January 6, 2020 12:29
workload - pg_stat_statements
-- based on pg_stat_statements only
with data as (
select
lower(regexp_replace(query, '^\W*(\w+)\W+.*$', '\1')) word,
count(*) cnt,
sum(calls) calls,
sum(total_time) total_time
from pg_stat_statements
--where not query ~* '^\W*set\W+' -- uncomment this to exclude `SET ...`
group by 1