We're using Go to write Dolt, the world's first version-controlled SQL database. This blog discusses how we sped up our table scans by 24% by avoiding

Mind The convT | DoltHub Blog

submited by
Style Pass
2025-01-17 22:30:06

We're using Go to write Dolt, the world's first version-controlled SQL database. This blog discusses how we sped up our table scans by 24% by avoiding interfaces at critical junctions.

They modularize code along lines of common behavior. The Pet and Person types below both implement String() methods, and can therefore be assigned to variables of type Stringer:

Fullfillment of those behaviors can be enforced at compile-time. The lines below will fail to compile if Person or Pet do not implement Stringer:

Behaviors as APIs define boundaries between logical layers. The Catalog class below has different implementations between our memory and dolt storage layers, but the engine logic is oblivious to how the integrator decides to satisfy the behavior.

Interfaces help aggregate higher order logic based on behavior. The function below tries to print the most verbose string behavior an object supports, or falls back to the built-in value formatter:

Leave a Comment