[Part 2] Architectural Decisions in Building Data Foundations for Agentic AI
Welcome to the series where we discuss architectural design decisions in building data foundations for agentic workflows.
The Series:
– Part 1: Operational vs Analytical Datastores — Choosing the Right Datastore for the Right Loop
– Part 2 : GraphRAG: From Decoupled Stacks to Multi-Model Engines
– Part 3 ++ : More design decisions
From Decoupled Stacks to Multi-Model Engines
When engineering teams transition AI agents from prototype to production, it is likely they hit a performance and accuracy wall. Standard Vector RAG, while easy to spin up, fails at complex enterprise reasoning. Meanwhile, assembling a “polyglot” stack of dedicated databases creates an operational nightmare. When autonomous agents need to make real-time, deterministic decisions over complex enterprise data, relying on fragmented vector databases and brittle ETL pipelines quickly leads to latency bottlenecks, sync lag, and ballooning operational costs.
In this post, we will explore the architectural trade-offs powering production AI systems — from why GraphRAG outperforms standard vector search, to how running native multi-model capabilities inside an integrated Operational Database can slash infrastructure TCO while delivering sub-50ms context to your AI agents.

A. Choosing Your Retrieval Strategy (Vector RAG vs Graph RAG)
- Vector RAG (Semantic & Similarity Search)
How it works: Documents are split into text chunks, converted into vector embeddings, and stored in a vector database. At query time, the system performs a cosine similarity search to retrieve the most semantically relevant chunks.
✅ Use Vector RAG when:
- Your queries are point-in-time or direct lookup questions: e.g., “What is the policy for expense reimbursement?” or “How do I configure logging in Python?”
- You are working mostly with unstructured text: Documents, PDFs, knowledge base articles, customer support tickets.
- You need low latency and fast indexing: Vector embeddings can be generated quickly and searched in milliseconds.
- You care about semantic similarity, not exact matching: Finding concepts that mean the same thing even if different words are used.
❌ Limitations of Vector RAG:
- Multi-hop reasoning is weak: Struggles with questions like “Which engineers worked on services that depend on Database X, and who are their stakeholders?”
2. Graph RAG (Knowledge Graph & Entity-Relationship Reasoning)
How it works: An LLM extracts entities (nodes) and relationships (edges) from your data to build a Knowledge Graph.
✅ Use Graph RAG when:
- Your domain is heavily interconnected: Financial transactions, fraud detection, supply chain logistics, legal contracts, healthcare/drug discovery, or organizational hierarchies.
- You need multi-hop and relational reasoning: e.g., “If Component A fails, which downstream customer-facing APIs and third-party vendors are impacted?”
- You need global corpus summarization: Questions like “What are the conflicting viewpoints across all project proposals?” Graph RAG traverses community summaries to synthesize global answers.
- Preventing relational hallucinations is critical: Explicit graph edges guarantee that facts like A is married to B or Company X acquired Company Y are preserved accurately.
❌ Limitations of Graph RAG:
- Higher indexing cost & latency: Extracting entities and edges using LLMs during ingestion is computationally expensive and slow compared to simple embedding generation.
- Schema & Maintenance complexity: Requires managing graph schemas and entity resolution (e.g., deduplicating “Google”, “Google LLC”, and “Alphabet” into a single node).
Hybrid RAG combines both:
- Use Vector Search to quickly locate the initial entry points (e.g., the top 5 most relevant document chunks or entity nodes).
- Use Graph Traversal to expand out from those nodes along their relationship edges, gathering vital context that standard vector search would have missed.
B. Real-World Architectural Approaches
Imagine a enterprise customer reports: “Our primary VoIP gateway is dropping packets during peak traffic hours after the recent network policy patch.”
An AI agent powered only by a Vector Database processes this prompt by looking for semantically similar text chunks across unstructured support tickets, KB articles, and incident logs.
- What Vector RAG retrieves: 10 different documents discussing “packet drops,” “VoIP gateways,” and “network policy updates.”
- Where Vector RAG fails: Vector embeddings measure semantic similarity, not causal structure. The vector database returns generic troubleshooting steps for VoIP packet loss. It cannot tell the agent that Router-7B (where the issue occurred) is physically tied to Subnet-104, which relies on Security Policy v4.2 updated 20 minutes ago.
- The Result: The agent gives a generic, unhelpful answer or hallucinates a non-existent root cause because it lacks the structural topology of the system.
GraphRAG combines semantic vector search with explicit graph traversals (Entity -> Relationship -> Entity). When the agent uses GraphRAG, it first uses vector search to identify the relevant entities (“VoIP Gateway”, “Network Policy”), and then traverses the Knowledge Graph. Because the agent receives both the unstructured knowledge (what packet loss means) and the exact operational topology (which specific policy deployment touched this exact gateway), it can deterministically identify the root cause and execute a precise rollback.
When building infrastructure for agentic AI, you have two ways to execute a GraphRAG pattern depending on your choice of database storage.
Approach I: GraphRAG on Specialized, Multi-Database Stacks
Implement GraphRAG by gluing together disparate systems:
- An agent queries a Dedicated Vector Database (e.g., Pinecone) to find relevant document chunks.
- The agent takes those entity IDs and queries a Dedicated Graph Database (e.g., Neo4j) over network calls to traverse relationships.
The Drawback: High operational friction, sync lag across systems, and multiple database clusters to manage.
Four critical limitations of multi-database stacks:
(i) Distributed Consistency and Sync Lag (Stale Context): When an agent acts on live transactional data, an ETL/CDC pipeline must sync that state to both the Vector DB and the Graph DB. Because this synchronization is asynchronous/eventually consistent, Agent Race Conditions occur. The agent might query the Vector or Graph DB immediately after an operational update and retrieve stale data, causing hallucinations or wrong decisions.
(ii) Network Hop Latency: To resolve a single step in a reasoning loop, the agent must make multi-stage network roundtrips: query the operational DB for user context, hit the Vector DB for semantic matching, and hit the Graph DB for relationships. Latency stacks up fast, killing real-time agent responsiveness.
(iii) Security & Governance Friction: Enforcing row-level security (RLS) across three separate databases means maintaining duplicate permission models in three places. If a security policy changes in the primary DB but hasn’t propagated to the Graph DB, your AI agent might leak sensitive data in its context window.
If User A is denied access to Document X in the Operational DB, you must ensure that same restriction is seamlessly enforced during Vector KNN search and Graph traversal. Fragmented IAM leads to data leaks.
(iv) DevOps & FinOps Overhead: You must manage three separate backup/restore schedules, Point-in-Time Recoveries (PITR — which must be synchronized across all three stores!), scaling policies, monitoring alerts, and vendor billing models.

Approach II: GraphRAG inside an Integrated Operational Database
Execute GraphRAG directly within a single unified database system like Spanner Graph or AlloyDB:
- The database holds operational data, vector embeddings, and graph edges inside the same physical cluster.
- The agent sends one single SQL/GQL query that performs the vector similarity search and traverses the graph edges natively on disk.
The Benefit: Zero network hop latency between databases, zero sync lag, and drastically simplified data governance.
GraphRAG is the intelligent retrieval method your AI agents need to understand complex domain relationships. An integrated Operational Database is the modern infrastructure platform that allows you to run patterns like GraphRAG without building complex, fragile ETL pipelines.
C. Converged Multi-Model Databases
The most efficient production alternative for operationalizing enterprise agents is moving toward Converged / Multi-Model Database Architectures, where operational, vector, and graph capabilities reside within a single engine or a closely coupled ecosystem.
- Google Cloud Spanner (Operational + Graph + Vector in One Engine)
- Spanner Graph allows Cypher queries (graph traversals) directly over the ACID relational operational tables with zero ETL.
- Spanner supports native Vector Search (K_NEAREST_NEIGHBORS) to store embeddings, relational entity data, and graph structures inside a single, globally distributed, strongly consistent database.
2. AlloyDB / PostgreSQL (Operational + Vector + Lightweight Graph)
- Use AlloyDB as core relational operational store.
- Use pgvector for high-performance vector indexing directly inside Postgres tables.
- Use relational views or JSON/Graph extensions for entity relationships.
Benefit: Single backup, unified Row-Level Security (RLS), ACID transactions, zero sync lag.
When to still use a decoupled Graph DB (like Neo4j): Only decouple if your graph structure is massive (billions of nodes/edges with deep 5+ hop traversals) and requires complex graph algorithms (like PageRank or Louvain community detection). For 90% of enterprise RAG and Agent workflows, a converged engine is vastly superior operationally.

D. Bringing It Together — Native GraphRAG inside Multi-Modal Integrated Operational Database
The most advantageous architectural design for enterprise agentic workflows is executing GraphRAG directly inside a single, Multi-Model Integrated Operational Database (such as Google Cloud Spanner with Spanner Graph or AlloyDB).
Real-World Example: Real-Time Fraud & Automated Account Containment
Consider an autonomous financial agent tasked with detecting and mitigating complex, multi-account fraud in real time.
The Workflow:
- A transaction arrives with an unusual prompt/payload.
- The Agent must instantly answer three questions:
- Semantic: Is this transaction description similar to known fraudulent phishing patterns?
- Graph/Structural: Is this account connected via shared IP, device ID, or wire destination to known malicious accounts?
- Operational: What is the customer’s current live balance and active status right now?
Instead of orchestration code managing three separate database calls over the network, the agent issues a single hybrid GQL/SQL query directly to the engine:
GRAPH FraudGraph
MATCH (acct:Account)-[e:TRANSFERRED_TO]->(target:Account)
WHERE COSINE_DISTANCE(acct.last_transaction_embedding, $flagged_pattern_vector) < 0.15
AND acct.status = 'ACTIVE'
AND target.risk_score > 80
RETURN acct.id AS compromised_account, SUM(e.amount) AS total_at_risk;
E. Technical Deep-Dive: Schemas, Co-location, and Execution Mechanics
To understand why an integrated database outpaces a decoupled architecture, let’s look past the API abstractions down to the disk storage and query optimizer levels.
Below is the blueprint for building a Real-Time Fraud & Automated Account Containment Engine inside a single database instance.
E.1 Spanner Graph: Multi-Model Schema Interleaving & Hybrid GQL/SQL
Let’s explore under-the-hood details when implementing with Spanner Graph:
- The Unified Schema Blueprint — Instead of maintaining a relational database for transactions, a vector database for embeddings, and a graph database for relationships, we define Nodes and Edges using standard SQL tables co-located in physical storage.
The Architectural Secret: Interleaved Co-location: Notice the INTERLEAVE IN PARENT Accounts clause on the AccountTransfers table. In standard relational databases, joining Accounts and Transfers causes high disk IOPS or distributed cross-network scans.
-- -----------------------------------------------------------------------------
-- 1. NODE TABLE: Accounts
-- Holds core transactional state AND vector embeddings for fast pattern matching.
-- -----------------------------------------------------------------------------
CREATE TABLE Accounts (
account_id STRING(64) NOT NULL,
customer_id STRING(64) NOT NULL,
status STRING(32) NOT NULL, -- e.g., 'ACTIVE', 'SUSPENDED'
risk_score INT64 NOT NULL,
last_login_ip STRING(45),
-- 768-dimensional vector embedding of recent account behavior/notes
behavior_embedding ARRAY<FLOAT32>(vector_length=>768),
updated_at TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp=true)
) PRIMARY KEY(account_id);
-- Create a Search Index on vectors directly inside the operational database
CREATE VECTOR INDEX idx_accounts_behavior_embedding
ON Accounts(behavior_embedding)
OPTIONS(distance_type='COSINE');
-- -----------------------------------------------------------------------------
-- 2. EDGE TABLE: AccountTransfers
-- Interleaved directly beneath 'Accounts' on disk for zero-latency traversal.
-- -----------------------------------------------------------------------------
CREATE TABLE AccountTransfers (
source_account_id STRING(64) NOT NULL,
transfer_id STRING(64) NOT NULL,
target_account_id STRING(64) NOT NULL,
amount NUMERIC NOT NULL,
transaction_time TIMESTAMP NOT NULL OPTIONS (allow_commit_timestamp=true),
) PRIMARY KEY(source_account_id, transfer_id),
INTERLEAVE IN PARENT Accounts ON DELETE CASCADE;
-- -----------------------------------------------------------------------------
-- 3. GRAPH PROPERTY DEFINITION
-- Exposes the relational tables to ISO GQL (Graph Query Language) without data duplication.
-- -----------------------------------------------------------------------------
CREATE PROPERTY GRAPH FraudGraph
NODE TABLES (
Accounts
KEY (account_id)
LABEL Account
PROPERTIES (account_id, status, risk_score, behavior_embedding)
)
EDGE TABLES (
AccountTransfers
KEY (source_account_id, transfer_id)
SOURCE KEY (source_account_id) REFERENCES Accounts(account_id)
DESTINATION KEY (target_account_id) REFERENCES Accounts(account_id)
LABEL TRANSFERRED_TO
PROPERTIES (amount, transaction_time)
);
2. The Unified Agent Query — When an AI agent detects a potential incident, it executes a single hybrid GQL/SQL statement that combines Vector Similarity Search, Graph Hop Traversal, and Relational State Filtering in one database call.
GRAPH FraudGraph
MATCH (src:Account)-[e:TRANSFERRED_TO]->(target:Account)
WHERE COSINE_DISTANCE(src.behavior_embedding, @flagged_pattern_vector) < 0.15
AND src.status = 'ACTIVE'
AND target.risk_score > 80
RETURN
src.account_id AS compromised_account,
target.account_id AS suspicious_target,
e.amount AS transfer_amount,
e.transaction_time AS transfer_time;
What Happens Step-by-Step Under the Hood:
- Vector Index Probe: The optimizer uses the Vector Index to perform an Approximate Nearest Neighbor search, rapidly narrowing millions of rows down to a candidate set of vectors matching @flagged_pattern_vector.
- Local Edge Pushdown: Because the edge table AccountTransfers is physically interleaved, the engine traverses from candidate source nodes to target nodes in local storage memory, completely bypassing network serialization overhead.
- Inline Relational Filtering: Real-time operational constraints (src.status = ‘ACTIVE’ and target.risk_score > 80) are applied during the memory scan step — preventing the engine from evaluating graph paths for accounts that are already disabled or low-risk.
By pushing graph reasoning and vector math down into the co-located operational storage layer, data teams eliminate entire classes of pipeline infrastructure while providing AI agents with sub-50ms deterministic reasoning capabilities.

E.2 AlloyDB AI: Adaptive Filtering & ScaNN Vector Indexing
When deploying standard PostgreSQL with pgvector for an agent, engineering teams possibly hit a wall called the “Pre-filtering vs. Post-filtering Dilemma.” If an agent applies a traditional SQL filter (e.g., WHERE status = ‘active’) alongside a vector search, a standard database either scans the entire B-Tree index first and drops the vector index, or vice-versa.
This can be fixed with AlloyDB AI at the database engine layer using ScaNN (Scalable Nearest Neighbors) and Adaptive Filtering.
The ScaNN Index
AlloyDB integrates Google’s proprietary ScaNN algorithm, which scales linearly up to billions of vectors using anisotropic quantization (compressing vectors while preserving the directional accuracy that LLMs depend on).
-- Enable the core engine extensions
CREATE EXTENSION IF NOT EXISTS vector;
CREATE EXTENSION IF NOT EXISTS alloydb_scann CASCADE;
-- Create the ultra-high-performance ScaNN index
CREATE INDEX idx_documents_embedding_scann
ON documents USING scann (embedding cosine)
WITH (num_leaves = 1000);
How Adaptive Filtering Saves Agent Computations
For an autonomous agent, data constraints change dynamically based on user prompts. AlloyDB’s query planner uses Inline Filtering to execute vector distance calculations and relational metadata filtering in tandem.
SELECT id, content, 1 - (embedding <=> $1::vector) AS similarity
FROM documents
WHERE category = 'Security_Logs'
AND tenant_id = 'enterprise_tenant_A'
ORDER BY embedding <=> $1::vector
LIMIT 5;
The Execution Plan:
- Bitmap Generation: AlloyDB hits standard B-Tree indexes on category and tenant_id to generate a rapid, internal bitmap (a list of valid row IDs).
- Quantized Vector Scan: Instead of searching the entire global ScaNN index, the engine matches the pre-filtered bitmap against the ScaNN index cluster (num_leaves).
- Anisotropic Distance Computation: It calculates vector distances only for the intersections, eliminating thousands of vector distance math operations (<=>) that would otherwise waste CPU cycles.
Eliminating the Data Pipeline: In-Database Embeddings
One of the slickest production detail is AlloyDB’s ability to generate embeddings natively via SQL. You can link your database directly to Vertex AI embedding models using virtual generated columns:
-- Let the database handle the pipeline automatically
ALTER TABLE documents ADD COLUMN embedding vector(768)
GENERATED ALWAYS AS (
google_ml.embedding('text-embedding-005', content)
) STORED;
When your data ingestion pipeline writes new text data to the content column, AlloyDB intercepts the transaction, securely hits the Vertex AI model endpoint, populates the embedding column, and commits the row atomically. For an agent, this guarantees zero sync lag — as soon as operational data is committed, it is instantly discoverable by the AI.
F. Conclusion: Stop Building Plumbing. Start Building Intelligence.
In a decoupled environment, senior data engineers spend their sprint capacity writing “glue code” — building retry logic, handling dead-letter queues, and debugging state drift across disparate database vendors. Consolidating into a multi-model integrated engine reclaims their time, allowing them to focus on building core AI capabilities rather than managing plumbing. The future of data infrastructure isn’t a stack of more specialized databases. It’s multi-model convergence.
Hope you found this article helpful.
Thank You.
Architect’s Guide to GraphRAG: From Decoupled Stacks to Multi-Model Engines was originally published in Google Cloud – Community on Medium, where people are continuing the conversation by highlighting and responding to this story.
Source Credit: https://medium.com/google-cloud/architects-guide-to-graphrag-from-decoupled-stacks-to-multi-model-engines-a2b00d47e2c6?source=rss—-e52cf94d98af—4
