One motivation for Melody was to stop asking application developers to manage indexes manually.

If the system knows the application’s queries at build time, it should have enough information to take responsibility for the structures that support them. The developer should describe the required answers and guarantees. The compiler should choose how to produce them.

But choosing indexes was only part of the idea.

A conventional database index, a search index, a materialized aggregate, and a cache all have something in common: the application does not write their contents independently. Their contents follow from other data.

They also share a surprising amount of machinery. They need to incorporate changes, handle deletions, recover after failures, and sometimes be rebuilt. They must stay sufficiently current for the operations that use them.

That machinery is part of the index.

The pipeline is part of the cost

Search makes this particularly visible.

An application writes to a database, and a separate pipeline copies changes into a search engine. The search engine owns one set of concerns. The database owns another. The application team often owns everything between them.

That can include change capture, transformation, retries, progress tracking, backfills, and reconciliation. It also includes answering questions such as: did the update fail, or did it succeed before the acknowledgement was lost? Can processing resume safely? Has a deletion reached every derived copy?

These responsibilities are often described as ETL or replication infrastructure and evaluated separately from the index itself. Yet they can be a major source of the feature’s cost and failures.

For Melody, the intended unit of design is the derived structure together with its maintenance and operation. Choosing a search index means accepting responsibility for keeping it useful and correct.

Freshness is an application requirement

People can be surprised to discover that a search system does not immediately reflect an acknowledged database write.

Once the reasons are explained—write throughput, implementation complexity, and cost—eventual consistency can be a reasonable tradeoff. A product catalog or documentation search may tolerate some delay.

But that tolerance has limits. “Eventually” rarely captures the whole requirement.

A support agent may need to find a ticket immediately after creating it. A dashboard may tolerate older results. A small application with a tiny, infrequently updated dataset may happily pay the cost of updating its search index in the same transaction as its source data.

There are several ways to satisfy these needs.

An implementation can maintain derived data synchronously with writes. It can maintain it asynchronously and make a read wait until the necessary updates have arrived. It can spend more on replication and maintenance capacity to reduce that wait. For some queries, it can recompute the answer directly.

Read-your-writes therefore does not prescribe synchronous maintenance. Nor is it identical to a current transactional read: ensuring that your own write is visible does not, by itself, establish all the guarantees of a consistent view of the database.

The application should express the guarantee it needs. The compiler should choose a mechanism that satisfies it, considering read latency, write latency, workload, and cost.

Today, changing these requirements can become a rewrite of the ingestion pipeline, query path, and deployment. Melody’s ambition is to let the requirement change without making the application author take ownership of that machinery.

Caches and incrementally maintained views

In the Score article, I described caching as a source of accidental changes to freshness, availability, and durability.

The broader thesis here is that caches are derived indexes. They retain a representation of authoritative information so that an answer can be obtained more cheaply.

That is why a cache is not something the author declares in Score. It is an implementation detail. The author declares the required result and its guarantees; the compiler may choose caching as a way to satisfy them.

There is an important boundary: if something called a cache contains the only copy of an acknowledged write, it has acquired an authoritative storage responsibility. It cannot be discarded and rebuilt like ordinary derived state.

Incremental view maintenance, or IVM, fits the same model.

Suppose an application needs total spending by customer. It could compute those totals whenever they are requested. Or it could maintain them as purchases are added, changed, and removed. IVM updates a derived result from changes to its inputs rather than repeatedly recomputing the whole result.

Neither approach is universally preferable. Maintaining results consumes work and storage. For a small dataset or an infrequently used query, recomputation may be cheaper.

The right index may be no index at all.

Score should describe the result. Melody should decide whether to compute it on demand, maintain it incrementally, or retain a cached result. Those choices must preserve more than the successful answer: ordering, missing values, errors, and the required view of the data matter too.

An optimization should not quietly change the application’s meaning.

Background work still has to be paid for

Moving maintenance off the write path does not remove its cost.

If changes arrive faster than an index can incorporate them, the system accumulates a backlog. That backlog consumes resources and increases lag. Retaining the history needed to catch up can itself become a substantial storage cost.

Eventually something must change: more resources, less admitted work, a different implementation, or an unmet freshness objective.

This connects derived indexes to both SLOs and admission control. The cost of a query includes the work required to maintain the structures that answer it. Its availability depends partly on whether that maintenance can keep up.

Rebuildability helps with recovery, but it is not free either.

A derived structure can be reconstructed when its source data and transformation remain available. Rebuilding may still require substantial compute, I/O, temporary storage, and time. The system must account for what happens to reads and incoming changes during that process.

These are implementation costs the compiler and operating system should expose, rather than leave hidden in a separately managed pipeline.

The compiler builds it; Release operates it

The division of responsibility we want is straightforward.

The compiler should generate the derived structures and the machinery that maintains them. Depending on the implementation, that may include change capture, incremental updates, progress tracking, and recovery.

Melody Release should deploy and operate that machinery: initialize it, manage its resources, observe lag and failures, coordinate rebuilding, and handle changes between releases.

The application author should not need to create a second system to make a compiler-selected index work.

We are building our own derived indexes and maintenance machinery. But, as with our exploration of Postgres as a target, we want to preserve the option of targeting existing platforms.

An external search engine or storage service could be a useful implementation when its capabilities fit the application’s requirements. That does not make every platform interchangeable. A target that cannot satisfy the required semantics must expose the limitation.

The application contract should remain independent of that choice.

Small applications should benefit too

Much of this machinery is associated with large systems because operating it is too complicated for small ones.

A blog may benefit from search. A browser application may benefit from incrementally maintained views. Neither should automatically require a fleet of services and a separately operated replication pipeline.

Specialized tools already make these features accessible. A client-side search library, for example, can be an excellent fit for a static site. But the application then owns its API, index format, loading behavior, and update process. Moving search to a server can mean replacing that integration.

Melody should make the capability portable. A compiler-selected implementation might be a small index inside a Wasm application, a structure maintained by a local database, or a service on another target.

Consider a static blog with server-hosted comments. Readers should be able to search the posts and comments together even though those sources live in different places and change at different rates.

Score should describe the searchable information and its required behavior. The compiler should determine where the supporting structures belong and how they receive updates. Moving the comments—or changing how posts are deployed—should not require the author to rebuild the search feature around a different library.

That is a broader form of portability than compiling the same code for another processor. Parts of the implementation can move across deployment boundaries while the application retains its meaning.

The same problem at enterprise scale

An internal support application provides a larger example.

Employees need to search tickets, product documentation, and customer records together. Documentation may tolerate some delay. An agent creating a ticket may need to find it immediately. The workload may grow from a modest dataset into a system serving many teams.

A conventional implementation can accumulate a search service, several ingestion paths, caches, backfill jobs, and monitoring for each connection.

In Melody’s intended model, the team declares the information it needs to search, its freshness requirements, and its SLOs. The compiler takes responsibility for the supporting structures and maintenance strategy; Release operates them.

If some source systems remain external, their capabilities still constrain what Melody can guarantee. Melody cannot manufacture timely updates that an upstream system does not provide. It should make that dependency visible.

The blog and the support application differ in scale and requirements, but they share the same underlying problem. Both need derived information that remains useful as data and deployments change.

Offline copies belong in the discussion

An offline device’s local data is often another derived view: a subset or representation of information needed for local use.

That introduces familiar concerns—what to retain, how to update it, how to detect missing changes, and how to catch up after reconnecting. Offline operation also requires the application to say what remains useful when current data cannot be obtained.

Pending local writes are different. An unsynchronized edit may be the only copy of new user information. It must be preserved and reconciled, not treated as a disposable index.

Placement and synchronization also need to preserve access rules. We will discuss Melody’s ownership model, and why it helps make these boundaries safer, in a separate note.

Where the design stands

The current design already gives the compiler responsibility for materialization and includes maintenance for a bounded set of aggregates. Other query shapes continue to use ordinary evaluation. Broader selection across engines, deployment targets, maintenance strategies, and cost objectives remains an ongoing design direction.

The objective is to make derived data an ordinary capability of an application.

The author describes the information the application needs and the guarantees it must preserve. Melody takes responsibility for the structures, the updates, and their operation—from a small browser application to a distributed service.