Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Columnar vs Row Storage: Two Ways to Lay Out the Same Table

Every database faces the same physical question: when a table is written to disk, what sits next to what? One option keeps all the fields of a single record adjacent, so a row is one contiguous blob. The other keeps one field across many records adjacent, so a column is one contiguous stream. The data is identical; only the arrangement changes. Yet that arrangement decides whether a query touches…

In the realm of database storage, two primary methods exist: row storage and columnar storage. Both approaches physically arrange data differently on disk, impacting how queries interact with the database.

Row storage organizes data by storing the fields of a single record next to each other, forming a contiguous blob. This layout optimizes for fetching and modifying whole records, making it ideal for online transaction processing where individual records are frequently accessed and updated based on a key. Updating a customer's balance, for instance, only requires touching one place in a row store.

Columnar storage, on the other hand, groups one field across many records adjacent, creating one contiguous stream for each field. This layout excels at reading a few fields across millions of records and is suited for analytics workloads. Queries focusing on specific fields, such as calculating the average balance across ten million customers, touch only the relevant column, resulting in faster scans and efficient data compression.

The choice between row and column storage hinges on the nature of the queries being executed. Row storage shines when queries focus on small writes and touching few columns, while column storage shines when scanning many rows and few columns is the norm. The performance trade-off lies in the balance between the queries' access patterns and the layout's inherent strengths.

Row storage, however, falters under wide analytical scans, as reading vast volumes of irrelevant fields can be inefficient. Teams may try to alleviate this by building separate summary tables, but this is simply a workaround for the inherent mismatch between layout and workload. Columnar storage struggles with high-frequency point updates, as constant small writes across many column files can overwhelm the system and impede query performance.

Modern databases often adopt a hybrid approach, maintaining a row-oriented buffer for recent writes while transitioning data into columnar format for analytical reads. The engine intelligently selects the most appropriate layout based on the query's age and access pattern, seamlessly providing both row and column storage capabilities without forcing engineers to make an upfront choice.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Nginx Hardening Checklist

Nginx ships with sensible defaults, but a default install is not a hardened one. Version numbers leak in headers, old virtual hosts answer for any hostname, security headers vanish on error pages, and…

  • Ensure Nginx and OpenSSL are up-to-date
  • Hide Nginx version by setting servertokens off
  • Redirect HTTP traffic and implement HSTS

Zero-Knowledge Rollups vs Optimistic Rollups: Two Ways to Trust a Chain

A blockchain that processes everything on the main chain is slow and expensive. Rollups move the work off-chain and post only a compact result back, but they disagree about how that result should be…

  • Zero-knowledge rollups use cryptographic proofs for transaction validation
  • Optimistic rollups rely on challenges and observer honesty for validation
  • Both methods achieve similar security but differ in trust mechanisms

TCP BBR vs CUBIC: Two Theories of How Fast to Send

Every TCP connection has to decide how fast to send without drowning the network. For decades the standard answer was to speed up until packets were lost, then slow down.

  • CUBIC algorithm reacts after packet loss, adjusts rate using cubic curve
  • BBR algorithm measures bandwidth and delay, sends data proactively
  • BBR excels on high-bandwidth, high-delay, or lossy paths, CUBIC on conventional networks

More from Thursday 26 November →