SShortSingh.
Back to feed

UUID v4 Primary Keys Bloat PostgreSQL Indexes Far More Than BIGINT or UUID v7

0
·2 views

A developer benchmarked three primary key types in PostgreSQL 17 by inserting 5 million rows into each table. Random UUID v4 keys produced an index 1.8 times the size of a BIGINT index, with roughly seven times as many pages written. UUID v7 keys, which begin with a timestamp, performed nearly as well as BIGINT. The gap comes from B-tree behavior: sequential keys append to the last page, while random keys scatter writes across the index and leave pages about 30% empty. The author notes that timing figures were noisy on a loaded laptop, while index size and page counts were consistent across rounds. The article recommends BIGINT as a simple default and UUID v7 when IDs are generated across many systems.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Guide Shows How to Scrape LinkedIn Job Postings Without Logging In

A developer tutorial explains how to collect LinkedIn job listings using public pages that are visible to logged-out visitors. It describes two sources: a paginated search endpoint that returns job cards with IDs, titles, companies, locations and posting dates, and individual job pages that include descriptions, criteria, applicant counts and sometimes salary. The author notes that some fields, such as external apply links, workplace type, job function and the poster, are only available to signed-in users or must be inferred from the text. The piece includes Python code using requests and BeautifulSoup, and the author discloses that they maintain a commercial LinkedIn jobs scraper on Apify. The approach was tested in November 2026.

0
ProgrammingDEV Community ·

dol8: A Python CI/CD gate that blocks pull requests with energy regressions

dol8 is an open-source CI/CD gate that stops pull requests from increasing a Python program's CPU energy use. It reads real RAPL energy measurements on bare-metal Linux and falls back to perf counters on virtual machines or CPU-time estimates on Windows. Its measurement core is written in Rust via PyO3, keeping the measurement separate from Python's own overhead, while Python handles statistics and orchestration. Every result is labeled with its measurement source and confidence, the gate avoids failing builds on noisy data, and comparisons across measurement types are blocked. The project is at v0.4-alpha under the MIT license, validated on AMD Ryzen, with Intel validation still in progress.

0
ProgrammingDEV Community ·

Kaze: A Go Terminal Client That Searches Multiple Sources and Drives mpv Over IPC

After repeated gaps in ani-cli, the developer built Kaze v4.3.0, a single static Go binary for Windows, macOS, and Linux that searches several sources at once. Queries run concurrently under a 3-second timeout, with results streamed into a Bubble Tea UI, and AUTO mode switches to another mirror when a CDN fails. The app controls mpv through IPC, using Unix sockets on Linux and macOS and Windows Named Pipes on Windows, which avoids shell injection and enables live shader swaps and skip-chapter controls. A security audit also removed an unsafe mpv TLS-bypass flag and added IP checks at dial time to block SSRF and DNS rebinding attacks.

0
ProgrammingDEV Community ·

A Single Line Made a Python Queue 2,500 Times Slower: Why list.pop(0) Is Costly

A developer found that processing one million tasks from a Python list took about 58 seconds because each pop(0) call shifted every remaining element. Replacing the list with collections.deque and using popleft() cut the runtime to roughly 0.023 seconds on Python 3.15.2 on an Apple M4. The article explains that list removal and insertion at the front cost O(n), so total work grows quadratically as data increases. It also covers related slowdowns, such as repeatedly building lists with out = out + [x] and string concatenation with += when the string has extra references. The author recommends deque for queues, append or += for lists, and str.join for building strings.