Ai4
Incremental view maintenance precomputes business logic on write, letting autonomous AI agents observe transactional state changes within one second while avoiding costly vector re-embeddings.
AI-assisted summary of Powering Agents with Search: Creating Interactive Vector Pipelines with SQL With Materialize — original source. Check the original for full context.
Source published:
Detailed notes
## Background Published on YouTube by the Ai4 channel on August 18, 2026, this presentation features Seth Wiesman, Field CTO at Materialize, exploring how to build interactive vector and search pipelines using SQL. The session description highlights methods for transforming operational data into semantic objects, selectively patching search indexes and embeddings, and keeping agent context fresh enough for reliable real-time action.
## TL;DR AI agents depend on an iterative observe-think-act loop, but production implementations frequently fail when agents make decisions over stale context. While dumping raw CDC streams into search engines causes slow multi-way query joins and batch data warehouses suffer from severe sawtooth staleness gaps, Incremental View Maintenance (IVM) precomputes business-level 'semantic objects' on write. This approach emits fine-grained data diffs that update live operational attributes instantly without triggering expensive vector re-embeddings for static text. By maintaining continuous freshness and deterministic sub-second response times, IVM establishes a live context graph that enables multi-agent workflows to interact with real-world state in real time.
## Atmosphere & style The presentation carries a sharp, pragmatic, and highly accessible engineering tone, demystifying complex data pipelines through vivid everyday analogies like keyless car entry and Chipotle ingredient prep. Wiesman delivers a structured, confident narrative arc that methodically deconstructs common architectural anti-patterns before detailing the incremental SQL solution. The overall feel is that of an engaging, high-signal conference masterclass, concluding with a grounded, practical Q&A session that honestly defines workload trade-offs and performance realities.
## Key takeaways - [00:04](https://www.youtube.com/watch?v=k5tTZwvMPos&t=4s) AI agents operate in an iterative Observe-Think-Act loop, where production failures most often stem from poor observation over stale or untrusted context rather than reasoning flaws. - [01:40](https://www.youtube.com/watch?v=k5tTZwvMPos&t=100s) Full-text search provides lexical matching and vector search enables semantic retrieval, but agents also require live operational attributes to determine whether an item is valid and actionable in the moment. - [03:25](https://www.youtube.com/watch?v=k5tTZwvMPos&t=205s) Interactive agents depend on immediate feedback with an architectural 'time to trusted action' reaction budget of roughly one second to verify the consequences of their actions. - [05:36](https://www.youtube.com/watch?v=k5tTZwvMPos&t=336s) Streaming raw CDC records directly into search engines forces agents to perform complex multi-way joins at read time, causing multi-second query latencies and infrastructure bottlenecks. - [07:21](https://www.youtube.com/watch?v=k5tTZwvMPos&t=441s) Precomputing raw data into unified semantic objects ahead of time minimizes token overhead in LLM prompts, improves reasoning accuracy, and ensures deterministic read performance. - [09:25](https://www.youtube.com/watch?v=k5tTZwvMPos&t=565s) Scheduled batch warehouse pipelines create a 'sawtooth staleness' pattern where agent actions remain invisible until the next batch run, reducing agents to purely read-only actors. - [11:41](https://www.youtube.com/watch?v=k5tTZwvMPos&t=701s) Incremental View Maintenance (IVM) solves staleness by computing work on write rather than read, maintaining materialized views using minimal mathematical deltas across complex SQL joins and aggregations. - [13:46](https://www.youtube.com/watch?v=k5tTZwvMPos&t=826s) Diff-driven incremental patching updates numerical or status attributes in search indices without triggering expensive vector re-embedding of static text fields. - [16:18](https://www.youtube.com/watch?v=k5tTZwvMPos&t=978s) Continuously updated semantic objects form an enterprise live context graph, allowing multi-agent production workflows to hand off tasks instantaneously without batch delay intervals. - [19:20](https://www.youtube.com/watch?v=k5tTZwvMPos&t=1160s) IVM achieves faster reaction times than querying normalized transactional databases directly by eliminating heavy on-the-fly SQL evaluations in favor of granular delta updates. - [21:10](https://www.youtube.com/watch?v=k5tTZwvMPos&t=1270s) IVM engines sit upstream of data warehouses adjacent to operational OLTP systems for real-time agent context, while data warehouses remain best suited for retrospective, exploratory analytics.
## Detailed walkthrough ### [00:04](https://www.youtube.com/watch?v=k5tTZwvMPos&t=4s) The Agent Loop and the Missing Ingredient: Live Trustworthy Context
An artificial intelligence agent fundamentally operates in an iterative loop: it observes the current state of the world, thinks using a large language model (LLM), and executes an action. That loop repeats continually until the agent reaches its designated goal. However, in moving agents from experimental lab environments into production systems, failures most frequently occur at the very first step: observation. If an agent cannot observe what is true in the exact moment it acts, reasoning capability becomes irrelevant—the model is merely hallucinating or calculating over stale and false premises, leading to actions that cannot advance the task.
To illustrate what agents lack, Seth Wiesman uses an everyday automotive analogy: modern keyless entry. When walking up to a locked car with the key fob in pocket, simply pulling the door handle prompts the vehicle to unlock and open immediately. The vehicle succeeds because it maintains live, trustworthy context about physical reality. It knows with certainty that the authorized driver is standing right next to that specific door with that specific key. Most current agent architectures completely lack this level of immediate, situated awareness.
```mermaid flowchart LR accTitle: The Agent Execution Loop subgraph Loop["Interactive Agent Loop"] direction LR O1["1. Observe<br/>(Real-World State)"] --> T["2. Think<br/>(LLM Reasoning)"] T --> A["3. Act<br/>(Execute Tool/Action)"] A --> O2["4. Observe Again<br/>(Inspect Consequence)"] end ```
[01:40](https://www.youtube.com/watch?v=k5tTZwvMPos&t=100s) Combining Full-Text Search, Vector Search, and Live Attributes
Because LLMs reason through natural language, the most intuitive mechanism for an agent to acquire context is by asking questions. Search serves as the bridge that translates natural language inquiries into structured context. When an agent searches for a known entity—such as querying a product catalog for "bananas"—traditional full-text search excels at retrieving direct lexical matches: organic bananas, banana bread, banana chips, or novelty t-shirts featuring dancing bananas.
When an agent grasps a conceptual intent without knowing the exact terminology, vector embeddings provide semantic reasoning by projecting meaning into multi-dimensional space. Under vector search, a query for "bananas" can surface "plantains"—an item whose textual description might never mention the word banana, but which remains, as Wiesman puts it, "scientifically speaking... pretty banana-y." Yet semantic similarity and lexical relevance only solve half the operational problem: - **Search and vectors** determine what items are conceptually *relevant*. - **Live operational attributes** determine what items are relevant *right now* (e.g., whether plantains are physically in stock, shippable to a specific user address, and accurately priced against running promotional discounts).
[03:25](https://www.youtube.com/watch?v=k5tTZwvMPos&t=205s) The Interactive Feedback Loop and the FreshMark Challenge
Truly autonomous agents depend on interactivity. Agents almost never "one-shot" complex goals; instead, they generate a plan and execute it incrementally. Just as a human software engineer using a coding agent relies on real-time feedback—checking if code compiles, verifying if unit tests pass, and adjusting course based on errors—an enterprise agent needs immediate verification of its actions. This requirement defines the core architectural North Star: **time to trusted action** (or reaction time), representing the duration between an event occurring in the physical or digital world and an agent being able to observe its consequence. For an interactive agent, this reaction budget must stay around approximately one second.
To ground this operational requirement, consider **FreshMark**, a hypothetical on-demand grocery platform functioning like a DoorDash for pantries. FreshMark coordinates customers, storefronts, couriers, inventory, and orders across a dense constellation of microservices and underlying databases. While FreshMark wants to deploy autonomous systems—such as automated customer support agents handling escalations or fleet dispatchers dynamically rerouting delivery vehicles—the engineering team faces the challenge of keeping the agent loop tightly coupled to transactional state.
[05:36](https://www.youtube.com/watch?v=k5tTZwvMPos&t=336s) The Naive Architecture: Dumping CDC into a Raw Search Index
A common initial pattern relies on standard enterprise plumbing: capturing change data capture (CDC) streams from microservices, relational databases, ERPs, and CRMs, and dumping the raw records straight into a shared search engine like Elasticsearch, OpenSearch, or Turbopuffer. Teams often assume that because the LLM is intelligent, it can stitch together the disparate raw records on the fly.
```mermaid flowchart TD accTitle: Naive CDC Pipeline to Search Index subgraph Sources["Raw Source Systems"] DB1["Orders DB"] DB2["Customers DB"] DB3["Couriers CRM"] end subgraph Pipeline["Ingestion & Search"] CDC["CDC / ETL Pipeline"] SI["Raw Search Index<br/>(Elastic / OpenSearch)"] end subgraph AgentLayer["Agent Execution"] Agent["Agent Context Read<br/>(Multi-second latency, High CPU)"] end
DB1 --> CDC DB2 --> CDC DB3 --> CDC CDC --> SI SI --> Agent ```
In practice, raw search indexes are not engineered to execute complex, multi-way joins across ten disparate source tables during an agent's context read. While data ingestion via CDC occurs rapidly, search queries become cripplingly slow. When FreshMark tested this setup with a single agent running in a loop, query times climbed to multi-second delays while database CPU spiked uncontrollably. Attempting to scale this pattern to production workloads causes the infrastructure to collapse because it forces the agent to reason over raw infrastructure abstractions rather than cohesive business entities.
[07:21](https://www.youtube.com/watch?v=k5tTZwvMPos&t=441s) Semantic Objects and Precomputing Context
When a support agent is onboarded, they do not care about entity-relationship diagrams, foreign keys, or the internal microservice topology; they simply need a unified representation of a "customer." These unified business entities are **semantic objects**—the foundational nouns of an enterprise (such as customers, orders, products, stores, and delivery trucks). Crucially, a semantic object is not merely a denormalized relational table. It integrates operational data directly with applied business logic: - A unified customer object must encapsulate the base customer record, active order history, current payment statuses, instant refund eligibility calculations, and governing policy rules. - Context queries must be **precomputed ahead of time** rather than aggregated on the fly, ensuring that servicing one agent or one million agents carries the same deterministic read cost in terms of infrastructure compute and query response time.
Precomputing semantic objects yields two major architectural advantages: - **Higher reasoning accuracy:** The agent's prompt context is no longer cluttered with low-level schema joins, relational artifacts, or raw policy scripts. The model focuses solely on resolving the user's immediate problem. - **Token efficiency:** Eliminating unneeded intermediate structural data drastically reduces the token footprint inside the LLM context window.
[09:25](https://www.youtube.com/watch?v=k5tTZwvMPos&t=565s) The Batch Warehouse Trap and the Chipotle Analogy
To avoid complex manual denormalization pipelines, teams frequently turn to data warehouses, data lakes, or "context lakes" running batch SQL models on cloud object storage. When FreshMark switched to scheduled analytical SQL runs, the context reads appeared solved: query latencies plummeted from multi-second delays down to single-digit milliseconds, remaining stable even when hundreds of agents queried the dataset simultaneously.
```mermaid flowchart TD accTitle: Batch Warehouse Sawtooth Staleness Pattern subgraph Ingest["Batch Warehouse / Lakehouse"] Storage["Cloud Object Storage"] --> BatchSQL["Scheduled SQL Batch<br/>(Hourly / Daily Refresh)"] end subgraph Query["Fast Reads vs Stale Data"] BatchSQL --> Precomputed["Precomputed Tables<br/>(Single-digit ms reads)"] Precomputed --> ReadAgent["Agent Read Loop"] ReadAgent -.->|"Action Taken"| Drift["Sawtooth Staleness Gap<br/>(Action consequences invisible until next batch)"] end ```
The victory is an illusion. While read latency becomes negligible, system reaction time degrades drastically into a "sawtooth pattern." Once an agent acts, the consequence of that action remains invisible until the next hourly or daily batch job completes. In the interim, context continually drifts away from real-world conditions, reducing an agent to a fundamentally "read-only" actor that cannot verify its own modifications.
To overcome this dilemma, Wiesman points to Chipotle's operational philosophy. Chipotle manages to serve meals that are simultaneously fast and fresh through continuous integration: raw ingredients arrive continuously and are proactively prepped and transformed into ready-to-serve components at the counter. Because the preparatory labor occurs proactively rather than at the moment of the order, any customer can walk up and assemble a custom steak bowl or chicken burrito instantly without sacrificing ingredient freshness. Building an interactive vector pipeline for production agents demands that exact same proactive, continuous model.
[11:41](https://www.youtube.com/watch?v=k5tTZwvMPos&t=701s) The Chipotle Metaphor: Incremental View Maintenance for Context Engineering
Context engineering can draw direct inspiration from Chipotle: the kitchen preps all the base ingredients ahead of time so that when a customer arrives, staff can assemble the final meal reactively and customize it on the spot. In data systems, engineers can continually integrate raw operational data and pre-aggregate it into structured semantic objects stored in a search index or vector database, while still granting the AI agent full runtime flexibility to assemble context in whatever shape it requires. Keeping these representations perpetually fresh has a long-established answer in computer science literature known as Incremental View Maintenance (IVM).
In traditional relational databases, a view is merely a syntactical convenience—a named query where the database re-executes all the underlying business logic from scratch whenever a user requests it. By contrast, an IVM engine proactively maintains the materialized output of that view as changes occur in the base tables, performing the computational work on write rather than on read. Crucially, "incremental" means the engine does not recompute entire datasets; it mathematically calculates the minimal delta required to patch the existing result set. This capability holds true even across arbitrarily complex SQL, including multi-way joins, window aggregations, and recursive graph-traversal queries. If a system contains a thousand customers and a single record updates, the database modifies only that specific affected row rather than churning through the remaining 999 records.
```mermaid flowchart LR accTitle: Incremental View Maintenance Pipeline subgraph Ingestion["Write Path"] A["OLTP Writes"] --> B["CDC Stream"] end subgraph Engine["Materialize / IVM"] B --> C["Incremental View Logic"] C --> D["State Diff Engine"] end subgraph Serving["Downstream Storage"] D --> E["Search Index / Vectors"] D --> F["Agent Context Layer"] end ```
[13:46](https://www.youtube.com/watch?v=k5tTZwvMPos&t=826s) Diffs for Free: Selective Index Patching and Cost-Efficient Embeddings
A major structural advantage of an incremental architecture is that it produces fine-grained data diffs essentially for free. When an update occurs, the engine emits precisely which rows and which columns changed. This granular change-tracking allows applications to patch external search indexes continuously without executing expensive, full-table overwrites. It also radically slashes machine learning costs associated with vector embeddings, because teams only pay an embedding model when text fields actually change.
In a typical product catalog, a product's text description may be embedded for semantic retrieval; while that description rarely changes, the available inventory count shifts up and down constantly throughout the business day. With diff-driven patching, the database pushes inventory updates into the search index immediately while leaving the vector embedding untouched, preventing the system from re-embedding the static description thousands of times unnecessarily. Consequently, response times for agent queries drop to the sub-second speed of simple point lookups, while reaction times—the latency between a write in the operational system and its availability in the index—become significantly faster than executing ad-hoc analytic queries directly against the source database.
- **Response Time:** Point-lookup query latencies remain on the same fast order of magnitude as a fully indexed data warehouse because pre-computations are already completed. - **Reaction Time:** Fresh writes become visible in roughly one second via continuous Change Data Capture (CDC) and incremental processing. - **Embedding Cost Optimization:** Vector endpoints are invoked strictly when embedded textual attributes change, rather than on every numerical or status change.
[16:18](https://www.youtube.com/watch?v=k5tTZwvMPos&t=978s) Interactive Multi-Agent Production Workflows and the Live Context Graph
Deploying this architecture to production transforms how operational support and fulfillment agents collaborate. For example, a customer support agent might receive an order request to supply an office party of 50 people with burrito bowl ingredients. Fulfilling that request requires live situational awareness: verifying the product catalog, confirming localized stock levels, validating shipping constraints, and enforcing dynamic budget rules. Because semantic objects are continuously maintained in search, the agent immediately discovers valid items and places the order autonomously.
The second an agent takes action, the updated order status, item pricing, and scheduled delivery times become instantly visible—not just to human operators monitoring administrative dashboards, but to downstream automated agents. A fulfillment agent can immediately pick up the newly generated order and trigger warehouse logistics in real time rather than waiting for an overnight batch pipeline. As more domains are introduced—customers, products, inventory, and fulfillment centers—these interconnected semantic objects coalesce into a real-time "live context graph" of the enterprise, allowing software agents to become fully interactive operational participants.
- **Fast Agent Actions:** Agents validate constraints (stock, budget, fulfillment windows) against freshly updated search indices in real time. - **Inter-Agent Hand-offs:** Upstream agent writes immediately trigger downstream consumer agents without batch-delay intervals. - **Enterprise Context Graph:** Models business relationships (customers place orders, orders comprise products, warehouses fulfill orders) dynamically in SQL. - **Enterprise Adoption:** Materialize powers operational architectures for organizations including Notion, Bilt Rewards, Crane Worldwide Logistics, and General Mills.
[19:20](https://www.youtube.com/watch?v=k5tTZwvMPos&t=1160s) Q&A: Unpacking Reaction Time vs. Source Queries
During the audience question-and-answer period, an attendee asked for clarification regarding the distinction between response time and reaction time, and how an IVM engine can boast a reaction time faster than querying the original data source directly. Seth Wiesman walked through an architectural comparison using a normalized relational database:
> "Let's say that you have a Postgres database. And you have data in there, and it's normalized across five tables. And we know to turn it into the customer object, you got to run a five-way join, and there's a window function, and there's some aggregation... If you query Postgres directly, yes, when a write occurs, it's visible instantaneously. But it has to run through that complicated query for you to see the result."
Because running that complex query over raw data can easily take ten seconds or more, the system's effective reaction time remains sluggish. With an IVM system, raw writes are streamed via CDC in a few milliseconds. The engine recognizes that only a single customer row was touched, applies the minimal delta calculation, and updates the pre-joined semantic record almost instantaneously. Because the incremental approach bypasses full-dataset scans and repeated join computations, changes become observable orders of magnitude faster than evaluating heavy analytical SQL directly against operational transactional tables.
[21:10](https://www.youtube.com/watch?v=k5tTZwvMPos&t=1270s) Q&A: Placement in the Data Stack and When Not to Use IVM
An audience member asked whether an IVM engine like Materialize must sit on top of an existing data lake, or how it functions if an organization lacks a lake entirely. Seth clarified that IVM platforms typically sit upstream of data warehouses and lakes, positioned directly adjacent to operational OLTP databases, CRMs, and ERPs. By the time data lands inside an enterprise data lake, it may already be an hour stale. To guarantee freshness, the IVM engine ingests live changes directly from operational data stores via CDC. Once clean semantic objects and customer views are computed, those enriched records can optionally be streamed back downstream into the data warehouse or lake, preventing the engineering organization from having to compute identical business logic twice.
When asked about anti-patterns, pitfalls, and when *not* to adopt an IVM system, Seth emphasized that no single technology is a universal panacea:
| Workload Dimension | Incremental View Maintenance (IVM) | Data Warehouse / Data Lake | |:--- |:--- |:--- | | **Primary Workload** | Interactive operational applications and live agent actions | Exploratory, retrospective, and ad-hoc analytical queries | | **Data Freshness** | Sub-second, real-time streaming updates via CDC | Batched, hourly, or daily ingest pipelines | | **Query Predictability** | Known semantic objects and structured operational views | Free-form exploratory queries without predefined access paths | | **Typical Use Case** | Powering agents, live inventory checks, real-time context | Quarterly executive sales reporting, broad marketing campaign retrospectives |
While running software agents directly against core OLTP databases is "almost exclusively a bad idea" due to resource contention and performance risks, IVM engines excel where agents require tightly looped, interactive access to shared business entities. Conversely, if an organization is building exploratory, read-only analytics—such as compiling an executive retrospective to determine why a previous quarter's marketing initiative succeeded or failed—traditional data warehouses remain the superior and recommended tool for the job.
## Notable quotes > How do you keep search indexes and vector databases fresh enough for an agent to act on? — Seth Wiesman
> Search has become the predominant way agents see the world. But keeping vectors and attributes up to date is complex, forcing teams to choose between stale documents, expensive batch updates, or complex pipelines. — Seth Wiesman
> patch your search index with only changed attributes and embeddings, and enrich results with fresh context to give agents the full picture. — Seth Wiesman
> [01:40](https://www.youtube.com/watch?v=k5tTZwvMPos&t=100s) scientifically speaking... pretty banana-y. — Seth Wiesman
> [03:25](https://www.youtube.com/watch?v=k5tTZwvMPos&t=205s) time to trusted action — Seth Wiesman
> [09:25](https://www.youtube.com/watch?v=k5tTZwvMPos&t=565s) sawtooth pattern — Seth Wiesman
> [16:18](https://www.youtube.com/watch?v=k5tTZwvMPos&t=978s) live context graph — Seth Wiesman
> [19:20](https://www.youtube.com/watch?v=k5tTZwvMPos&t=1160s) Let's say that you have a Postgres database. And you have data in there, and it's normalized across five tables. And we know to turn it into the customer object, you got to run a five-way join, and there's a window function, and there's some aggregation... If you query Postgres directly, yes, when a write occurs, it's visible instantaneously. But it has to run through that complicated query for you to see the result. — Seth Wiesman
> [21:10](https://www.youtube.com/watch?v=k5tTZwvMPos&t=1270s) almost exclusively a bad idea — Seth Wiesman
## Mentioned Seth Wiesman, Materialize, Ai4, FreshMark, DoorDash, Elasticsearch, OpenSearch, Turbopuffer, Chipotle, Postgres, Notion, Bilt Rewards, Crane Worldwide Logistics, General Mills
## Video description Seth Wiesman - Field CTO, Materialize
How do you keep search indexes and vector databases fresh enough for an agent to act on? Search has become the predominant way agents see the world. But keeping vectors and attributes up to date is complex, forcing teams to choose between stale documents, expensive batch updates, or complex pipelines. This talk will show how to architect a search pipeline in SQL that keeps your search index up to date and trustworthy enough for agents to rely upon. You'll learn how to transform your operational data into documents and semantic objects, patch your search index with only changed attributes and embeddings, and enrich results with fresh context to give agents the full picture. Attend if you're deploying AI agents to production and want to give them fresher, more complete context, and tighten their read-act-react loop.
[Source](https://www.youtube.com/watch?v=k5tTZwvMPos)