Skip to content

Instantly share code, notes, and snippets.

View revilon1991's full-sized avatar
🐈
work hard, play hard

Evgenii Kuznetsov revilon1991

🐈
work hard, play hard
View GitHub Profile

What is a Page Split and Its Impact on Database Fragmentation

A Page Split occurs in B-trees (the underlying structure of most database indexes) when a new record is inserted into a full data page. To make room, the database engine splits the page into two, redistributes the records, and updates the index pointers.

Why Does a Page Split Cause Fragmentation?

  1. Breaks Physical Order – The new page may be allocated in a different location, disrupting the sequential structure of the data.
  2. Extra Redistribution Costs – Each split requires modifying adjacent pages and potentially updating parent nodes, increasing system load.
  3. Decreased Read Efficiency – Fragmentation forces the database to perform additional I/O operations when reading sequential data.
@revilon1991
revilon1991 / goroutines.go
Created October 13, 2024 07:09
Golang API, WaitGroup, Semaphore, Cancel Context, Recovery Panic, Safe Map Mutex Result goroutine
package main
import (
"context"
"encoding/json"
"fmt"
"net/http"
"runtime/debug"
"strconv"
"sync"
@revilon1991
revilon1991 / gcal_countries.py
Last active July 3, 2024 13:32 — forked from seanblanchfield/gcal_countries.py
Google calendar public holiday names by country
# Complete mapping of ISO 3166 2-letter country codes to descriptions used in Google calendar URLs, accurate as of 29 July 2021.
iso_to_gcal_description = {
"ad": "ad",
"ae": "ae",
"af": "af",
"ag": "ag",
"ai": "ai",
"al": "al",
"am": "am",
# Majority Grouping
select concat(repeat('*', floor(a.trCount / 100))) as bar,
floor(avg(a.trCount)) as avgTrCnt,
max(a.trCount) as maxTrCnt,
min(a.trCount) as minTrCnt,
count(*) as accountCnt
from Account a
where 1
and a.trCount > 10
group by bar
@revilon1991
revilon1991 / mysql_lock.md
Last active March 23, 2025 14:05
MySQL InnoDB synthetic lock

Совместимость типов блокировок на уровне таблицы представлена в следующей матрице

X IX S IS
X Конфликт Конфликт Конфликт Конфликт
IX Конфликт Совместимо Конфликт Совместимо
S Конфликт Конфликт Совместимо Совместимо
IS Конфликт Совместимо Совместимо Совместимо
  • S-блокировка позволяет транзакции, которая удерживает блокировку, читать строку.
  • X-блокировка позволяет транзакции, которая удерживает блокировку, обновлять или удалять строку.
@revilon1991
revilon1991 / AppController.php
Created January 9, 2023 20:06
CRUD symfony form with ManyToMany relations
<?php
declare(strict_types=1);
namespace App\Controller;
use App\Entity\Article;
use App\Entity\ArticleHasTag;
use App\Entity\Tag;
use Doctrine\Common\Collections\ArrayCollection;
@revilon1991
revilon1991 / restartTouchPad.sh
Last active September 2, 2022 15:36
When you macbook tuchpad is broken and does'nt work multi touch
launchctl stop com.apple.Dock.agent
<?php
// here installed https://github.com/dragonmantank/cron-expression
require_once '/Users/ekuznetsov/projects/pamyatki/vendor/autoload.php';
// current time is 2022-08-18 18:30:30
date_default_timezone_set('Europe/Moscow');
$c = new \Cron\CronExpression('0 0 1 * *');
@revilon1991
revilon1991 / RESTAPI.md
Last active July 6, 2022 07:44
REST API Recommendation

REST API

Схема доставки ресурса от клиента до бекенда.

  • В колонке result учитывается состояние модели полученное хендлером (не БД)
  • Required - означает, что поле должно фигурировать в запросе, иначе ошибка.
  • Default - если значение по умолчанию не было задано, оно рассматривается как null. api

Определения параметров в GET запросах

Есть три основных параметра, которые передаются в формате массива/значения

@revilon1991
revilon1991 / worklog.php
Created January 21, 2022 16:37
Jira worklog with php
#!/usr/bin/env php
<?php
const JIRA_HOST = ''; // ex. github.atlassian.net
const USERNAME = ''; // ex. [email protected]
const TOKEN = ''; // from https://id.atlassian.com/manage-profile/security/api-tokens
[, $task, $time] = $argv;
$ch = curl_init();