How Property Graphs Work with Vector Search in Oracle 26ai for Connected Data

Oracle 26ai unifies property graphs and vector search by storing high-dimensional embeddings directly in relational tables that serve as graph vertices and edges, enabling single SQL statements that traverse multi-hop relationships while filtering results by semantic similarity using VECTOR_DISTANCE() and GRAPH_TABLE syntax.

Oracle 26ai (formerly 23ai) extends the classic relational model with two first-class data types essential for modern AI applications: the VECTOR column type and the Property Graph (SQL/PGQ) view. According to the oracle-devrel/oracle-ai-developer-hub repository, this dual architecture allows developers to query connected data using graph traversal patterns while simultaneously ranking results by vector similarity, all within a single ACID-compliant database transaction.

The Dual Data Model: Vectors and Property Graphs

Oracle 26ai treats vectors and graphs as complementary rather than competing technologies. The database stores embeddings in ordinary tables, then exposes those tables as a metadata-only property graph view that maps rows to vertices and foreign key relationships to edges.

Native VECTOR Column Support

The VECTOR data type stores high-dimensional embeddings (e.g., VECTOR(1536, FLOAT32)) directly inside standard relational tables. You can build HNSW indexes for approximate nearest-neighbor (ANN) search and calculate similarity using the VECTOR_DISTANCE() function with metrics like COSINE. This enables semantic memory—fast similarity search over text, images, or any vectorized artifact without external vector databases.

Property Graph (SQL/PGQ) Views

A property graph in Oracle 26ai is a metadata-only view defined using CREATE PROPERTY GRAPH. It maps existing relational tables to vertex and edge types without duplicating data. Edge tables preserve rich properties such as confidence, t_valid, and t_invalid timestamps. The optimizer rewrites GRAPH_TABLE queries and PGQL (Property Graph Query Language) statements into ordinary SQL joins, allowing you to traverse relationships using pattern-matching syntax like (e1 IS entity) -[f IS fact]->{1,3} (e2 IS entity).

Combining these technologies addresses limitations of using either approach in isolation:

  • Multi-hop reasoning – Graph traversal finds chains of facts linking a query to an answer (e.g., discovering which university an Olympian graduated from by traversing person -> attended -> university edges).
  • Semantic grounding – Vector similarity ranks candidate nodes during traversal, ensuring retrieved sub-graphs remain relevant to the user's intent even when keyword matches fail.
  • Single-transaction guarantee – Both graph structure and vector embeddings live in the same schema, so updates to chat history, embeddings, and graph edges are atomic.
  • No external infrastructure – Eliminates the need for separate Neo4j or external vector databases; everything runs inside Oracle 26ai.

Implementation Architecture

The architecture follows three distinct layers as documented in apps/oracle-database-java-agent-memory/docs/todos/graph_knowledge/knowledge_graph_intro.md:

  1. Persist entities and facts in relational tables containing VECTOR columns (e.g., agent_entities.embedding and agent_facts.fact_embedding).
  2. Define a property graph using CREATE PROPERTY GRAPH to map those tables to vertex (entity) and edge (fact) types. The graph remains a view; no data is duplicated.
  3. Execute hybrid queries that use GRAPH_TABLE to retrieve a sub-graph, then join back to underlying tables to apply VECTOR_DISTANCE() filters. The Oracle optimizer fuses these paths into a single execution plan.

Practical SQL Examples

The following examples are derived from the knowledge graph implementation in apps/oracle-database-java-agent-memory/docs/todos/graph_knowledge/knowledge_graph_intro.md.

Creating Relational Tables with Vector Columns

First, create tables that store both structured attributes and vector embeddings:

-- Entities (e.g., people, organizations, concepts)
CREATE TABLE agent_entities (
    entity_id   NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    name        VARCHAR2(500) NOT NULL,
    entity_type VARCHAR2(100),
    summary     VARCHAR2(4000),
    embedding   VECTOR(1536, FLOAT32),          -- Vector memory storage
    importance  NUMBER DEFAULT 0.5,
    access_count NUMBER DEFAULT 0,
    last_accessed TIMESTAMP DEFAULT SYSTIMESTAMP,
    created_at  TIMESTAMP DEFAULT SYSTIMESTAMP,
    archived    NUMBER(1) DEFAULT 0
);

-- Facts (edges) linking two entities
CREATE TABLE agent_facts (
    fact_id            NUMBER GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
    source_entity_id   NUMBER REFERENCES agent_entities(entity_id),
    target_entity_id   NUMBER REFERENCES agent_entities(entity_id),
    predicate          VARCHAR2(200),              -- Edge label
    description        VARCHAR2(4000),
    fact_embedding     VECTOR(1536, FLOAT32),      -- Vector for fact text
    confidence         NUMBER DEFAULT 0.8,
    t_valid            TIMESTAMP,                  -- Validity start
    t_invalid          TIMESTAMP,                  -- NULL = still valid
    t_created          TIMESTAMP DEFAULT SYSTIMESTAMP,
    source_episode_ids VARCHAR2(4000)               -- JSON array of episodes
);

See lines 99-124 in the knowledge graph intro file for the complete DDL.

Defining the Property Graph Metadata

Create the graph view that maps these tables to vertices and edges:

CREATE PROPERTY GRAPH agent_memory_graph
  VERTEX TABLES (
    agent_entities KEY (entity_id)
      LABEL entity
      PROPERTIES ALL COLUMNS
  )
  EDGE TABLES (
    agent_facts KEY (fact_id)
      SOURCE KEY (source_entity_id) REFERENCES agent_entities (entity_id)
      DESTINATION KEY (target_entity_id) REFERENCES agent_entities (entity_id)
      LABEL fact
      PROPERTIES ALL COLUMNS
  );

This metadata-only definition appears at lines 126-139 in the source documentation.

Pure Graph Traversal Queries

Perform multi-hop traversals using GRAPH_TABLE syntax to find connected entities:

SELECT gt.source_name,
       gt.predicate,
       gt.target_name,
       gt.description
FROM GRAPH_TABLE(agent_memory_graph
    MATCH (e1 IS entity) -[f IS fact]->{1,3} (e2 IS entity)
    WHERE e1.name = :entity_name
      AND f.t_invalid IS NULL
    COLUMNS (e1.name AS source_name,
             f.predicate,
             e2.name AS target_name,
             f.description)
) gt
ORDER BY gt.predicate;

This pattern match traverses 1 to 3 hops (lines 144-152).

Hybrid Graph and Vector Search Queries

Combine graph traversal with vector similarity filtering in a single statement:

SELECT gt.target_name,
       gt.predicate,
       VECTOR_DISTANCE(e.embedding, :query_vector, COSINE) AS similarity
FROM GRAPH_TABLE(agent_memory_graph
    MATCH (e1 IS entity) -[f IS fact]->{1,3} (e2 IS entity)
    WHERE e1.name = 'Artificial Intelligence'
      AND f.t_invalid IS NULL
    COLUMNS (e2.entity_id AS target_id,
             e2.name      AS target_name,
             f.predicate)
) gt
JOIN agent_entities e ON e.entity_id = gt.target_id
WHERE VECTOR_DISTANCE(e.embedding, :query_vector, COSINE) < 0.4
ORDER BY similarity
FETCH FIRST 20 ROWS ONLY;

This hybrid approach (lines 159-174) retrieves entities within a 3-hop graph neighborhood, then filters and ranks them by cosine similarity to a query vector.

Advanced PGQL Path Queries

For complex pathfinding, use PGQL (Property Graph Query Language) directly:

-- Shortest path between two entities
SELECT COUNT(e) AS num_hops,
       ARRAY_AGG(n.name) AS path_nodes
FROM MATCH ANY SHORTEST (p1:entity) (-[e]-(n))* (p2:entity)
    ON agent_memory_graph
WHERE p1.name = 'Alice' AND p2.name = 'ProjectX'
ORDER BY num_hops;

PGQL syntax examples appear at lines 176-186 in the documentation.

Key Implementation Files

The oracle-devrel/oracle-ai-developer-hub repository contains several reference implementations demonstrating this architecture:

Summary

  • Oracle 26ai stores vector embeddings in standard relational columns (VECTOR type) and exposes them as property graph vertices/edges via metadata-only views.
  • The GRAPH_TABLE SQL extension and PGQL allow multi-hop traversal of relationships while VECTOR_DISTANCE() enables semantic ranking of results.
  • Hybrid queries execute as single SQL statements with ACID guarantees, eliminating the need for separate graph databases or vector stores.
  • Edge properties like confidence and t_valid support temporal and probabilistic reasoning over connected data.
  • All examples are implemented in the oracle-ai-developer-hub repository using standard SQL/PGQ syntax compatible with Oracle 26ai.

Frequently Asked Questions

What is the difference between a property graph and a vector index in Oracle 26ai?

A property graph is a metadata view that maps relational tables to vertices and edges, enabling traversal queries via GRAPH_TABLE or PGQL. A vector index (such as HNSW) is built on a VECTOR column to accelerate approximate nearest-neighbor searches using VECTOR_DISTANCE(). The property graph handles structured connectivity, while the vector index handles semantic similarity; Oracle 26ai allows you to use both in the same query.

How does the Oracle 26ai optimizer handle hybrid graph and vector queries?

The Oracle optimizer rewrites GRAPH_TABLE pattern matches into standard SQL joins, then fuses these with vector distance calculations into a single execution plan. This means filtering by VECTOR_DISTANCE() happens within the same query execution as graph traversal, without requiring round-trips between separate systems or manual application-side joining.

Can I use property graphs with vector search without duplicating data?

Yes. Property graphs in Oracle 26ai are metadata-only views created with CREATE PROPERTY GRAPH. They reference underlying relational tables directly without copying data. When you store vectors in those underlying tables (e.g., agent_entities.embedding), the graph view automatically exposes those vectors to hybrid queries without duplication.

What are the performance benefits of combining graph traversal with vector similarity?

Combining these technologies reduces latency and complexity by eliminating network hops to external vector databases or graph stores. The database can prune graph traversal paths early using vector similarity thresholds, and HNSW indexes ensure that similarity calculations remain fast even with millions of embeddings. This architecture supports real-time AI agent memory systems where multi-hop reasoning must return semantically relevant results within milliseconds.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →