Shorts: July 2026
2 Shorts posted in July 2026, each with a short summary. The same summaries in Japanese follow below.
-
How Database Indexes Work
Without an index, finding one row among a million means checking them one by one. A B-tree compares values at each node to pick a branch, so even a million rows need a tree only three levels tall, and the bottleneck is disk I/O, not searching inside a node. Real databases use B+ trees, which keep data only in linked leaves for easy range scans, and split full nodes as data grows so lookups stay fast.
Watch on YouTube -
How JPEG Compression Works
JPEG compresses images in five steps. It converts RGB to YCbCr to separate brightness from color, then lowers only the color resolution through chroma subsampling, since the eye is less sensitive to fine color changes. It splits the image into 8x8 blocks and applies the discrete cosine transform, quantizes the coefficients so fine detail becomes zero, which causes the block noise of low-quality JPEGs, and finally reads them in zigzag order, groups runs of zeros and applies Huffman coding.
Watch on YouTube
2026年7月のショート動画
2026年7月に投稿したショート動画 2 本の要約です。
-
【データベース】インデックスの仕組み
インデックスがなければ、100万件の中から1件を探すのに端から順に確認するしかありません。B木は各ノードで値を比べて進む枝を選ぶので、100万件でも木の高さはわずか3段で済みます。ボトルネックはノード内の探索ではなくディスクのI/Oです。実際のデータベースが使うB+木は、データをつながったリーフにだけ置くので範囲検索もしやすく、データが増えるとノードを分裂させて探す速さを保ちます。
-
JPEGの仕組み
JPEGは5つのステップで画像を圧縮します。RGBをYCbCrに変換して明るさと色を分け、人の目は色の細かい変化に鈍いので、クロマサブサンプリングで色の解像度だけを下げます。次に画像を8×8ピクセルのブロックに分けて離散コサイン変換をかけ、量子化で目に見えにくい細かい成分を0に切り捨てます。これが低画質JPEGのブロックノイズの正体です。最後に係数をジグザグの順に読み出し、続く0をまとめ、ハフマン符号化で短いビットに置き換えます。