LOOMBYTE / NAVIGATION

BUILD. LEARN. SHIP.

ENGINEERING NOTES / UNDER THE SURFACE

Every decision
has a trade-off.

The architecture that changed. The query that needed investigation. The fix that held up under testing. This is where we document the reasoning.

01

Start with a problem.

Define what is happening and why it matters before proposing a solution.

02

Follow the evidence.

Form a hypothesis, measure the baseline, and run a focused experiment.

03

Explain the result.

Document the fix, its limits, and what the investigation changed.

engineering / / 6 MIN READ

The Database Query That Was Slowing Everything Down

A forensic look into unindexed foreign key lookups under concurrent writes, and how rewriting the access pattern restored single-digit latencies.

Read the note

When measuring latency, averages hide the real failures. During load testing, our dashboard endpoint degraded from an acceptable 150ms to over 800ms at the 99th percentile.

### The Investigation

Profiling the database using EXPLAIN (ANALYZE, BUFFERS) revealed that a seemingly innocuous JOIN across tenant records was triggering full sequential scans. PostgreSQL query planning opted for sequential scans because the foreign key columns were missing covering indexes for active tenant partitions.

### The Fix

Rather than throwing more CPU cores at the database, we tackled the access pattern directly: 1. Created a compound partial index scoped exclusively to active records. 2. Refactored the query from a monolithic join into a parameterized Common Table Expression (CTE) with bounded memory limits.

### The Result

Latency dropped from 800ms to 120ms at p99, and the buffer cache hit ratio rose to 99.4%. The biggest lesson: query planning behavior shifts dramatically once data volume passes cache boundaries. Always test query plans with realistic data distributions.

engineering / / 8 MIN READ

Why We Didn't Add Microservices

Premature distributed architectures trade in-process reliability for network failure modes. Here is the operational analysis behind keeping the monolith modular.

Read the note

Splitting a system into microservices before establishing bounded contexts introduces distributed state problems, complex serialization overhead, and network partition vulnerabilities without solving underlying code clarity.

By adhering to a modular monolith with strictly enforced domain boundaries, we retained instant compile-time safety, atomic transactions, and straightforward local testing while keeping deployment overhead minimal.

engineering / / 5 MIN READ

When Clean Architecture Becomes Overengineering

Separating concerns is good engineering. Adding 6 layers of indirection for a simple CRUD operation is not. Where we draw the boundary.

Read the note

Clean Architecture principles provide valuable mental models for isolating core business rules from external frameworks. However, applying repository patterns, use-case interactors, and redundant DTO mappers to straightforward data pipelines frequently introduces maintenance friction without measurable decoupling benefit.

We evaluate architectural boundaries through one question: does this abstraction allow us to test or swap components independently without touching business logic? If the answer is no, the abstraction is dead weight.