UUIDv4 vs. UUIDv7: Why Order Matters for Database Indexes

UUIDv4 and UUIDv7 are both 128-bit identifiers, but they organize their bits differently. UUIDv4 uses random data, while UUIDv7 begins with a millisecond timestamp, followed by random data or optional ordering components. This makes UUIDv7 approximately chronological when sorted.

The main database advantage is better locality in B-tree indexes.

With UUIDv4, new keys land throughout the index. Inserts can touch many different pages, increasing cache misses and disk activity. Splitting full pages can also leave space unevenly utilized.

With UUIDv7, newly generated keys usually land near the end of the index. As a result, inserts repeatedly access a smaller set of pages. This can provide:

  • Better cache efficiency, because recently accessed pages are reused.
  • Less scattered I/O, especially when the index exceeds available memory.
  • Better page utilization and potentially fewer disruptive page splits.

These are workload-dependent benefits, not guaranteed speedups. RFC 9562 explicitly identifies poor database-index locality as a limitation of random UUIDs.

UUIDv7 still occupies 16 bytes and exposes its generation timestamp. It also does not guarantee exact creation order across machines or within the same millisecond.

My projects

Here I want to share some information about my pet projects I am working on right now:

Turn your Google translate dictionary into learning flash cards. The problem is simple – learn words from Google Translate dictionary
https://gtlearn.mcher.dev

Pretty often I use some tools in my daily work, for example, to estimate costs in cloud environment – I want to know size in bytes which one typical information item will take. It is very important if you are working on high load application, like millions requests per day, and every request has at least 400 bytes of payload – gigabytes of storage should be reserved
https://tools.mcher.dev/
https://tools.mcher.dev/stringsizecalc/

base64 encoding, decoding
https://tools.mcher.dev/base64/

password generator
https://tools.mcher.dev/passwordgen/

url parser and builder
https://tools.mcher.dev/urlbuilder/

Turn existing folder into git repository

First of all let me write about initial conditions:

  • I have folder on my computer’s disk with code
  • I have a new empty repository on github

Our great plan consists of following points:

  1. Navigate to project folder:
    • $ cd /path/to/project
  2. Add files to the repository:
    • $ git init
    • $ git add . (don’t forget about point sign)
    • $ git commit -m “first commit”
  3. After we have to connect to our remote repository:
    • $ git remote add origin https://github.com/mygitaccount/mynewproj.git
  4. Push files on remote server and create new branch “master” on our new github repository
    • $ git push -u origin master
  5. Last thing, type the following command:
    • $ git push

Now all your files in github repository, congratulations!
If you want to check current state type
$ git status – it shows active branch, and other useful information.
$ git branch – shows all available branches

Links:
https://git-scm.com/doc
https://wiki.epfl.ch/help-git-en/how-can-i-import-an-existing-folder-into-my-repository

Kotlin. Я учусь. setContentView

Как задать нужный экран (view) для activity?

1. В AndroidManifest.xml я должен указать имя класса, который будет отвечать за эту activity:

<activity android:name=".MainActivity">

2. В классе MainActivity в методе onCreate нужно вызвать метод setContentView:

setContentView(R.layout.activity_main)

Таймер Табата

Весна 2020. В мире пандемия короновируса, который вызвал кризис, последствия которого никто предсказать не может.

На данный момент жители многих стран вынуждены сидеть дома на карантине / в самоизоляции. Закрыты многие кафе, спортзалы, другие общественные места.

В принципе, в самоизоляции можно найти плюсы. Я например, решил, что не хочу терять физическую форму, находясь дома, поэтому занимаюсь табатой – интенсивными интервальными тренировками.

Более того, я смог с помощью этих тренировок сбросить около 5ти килограмм.

На волне такого успеха (а для меня это успех) я решил написать свой табата-таймер.
В планах:
1. добавить английский язык
2. сохранение тренировок (последовательность упражнений)
3. галерея упражнений
4. мобильное приложение (ууух!)

Сейчас же таймер может быть запущен сразу на один круг, либо можно настроить под свою индивидуальную тренировку

Medium underline style

Interesting approach to draw underline from medium by Martin Wichary
text-decoration: none;
background-repeat: repeat-x;
background-image: linear-gradient(to right,rgba(0,0,0,.84) 100%,rgba(0,0,0,0) 0);
background-image: linear-gradient(to right,currentColor 100%,currentColor 0);
background-image: url(data:image/svg+xml;utf8,);
background-size: 1px 1px;
background-position: 0 1.05em;
background-position: 0 calc(1em + 1px);

Javascript Singleton

Ссылки на хорошие материалы по реализации данного паттерна.

singletone

var Singletone = (function () {
	var instance;

	return function Construct_singletone () {
		if (instance) {
			return instance;
		}
		if (this && this.constructor === Construct_singletone) {
			instance = this;
		} else {
			return new Construct_singletone();
		}
	}
}());

И еще:
medium