Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Beyond Vector Search: Graph-Augmented RAG with ...

Beyond Vector Search: Graph-Augmented RAG with PostgreSQL SQL/PGQ

Presented at PGConf.Asia 2026, Hong Kong, November 17, 2026.
https://pgconf.asia/EN/2026/

Vector search is a useful starting point for RAG, but enterprise knowledge is more than text. Relationships between people, companies, events, and documents provide important context that vector similarity alone cannot capture.

This talk explores how PostgreSQL can combine pgvector, SQL, and SQL/PGQ to support Graph-Augmented RAG. Using a practical example, it shows how vector search finds relevant documents while graph queries connect them to entities, relationships, and supporting evidence.

The session also introduces the SQL/PGQ and GQL standards and discusses ongoing SQL/PGQ development for PostgreSQL 20 and beyond.

Key takeaway: Knowledge is more than text. Relationships give it context.

Koji Annoura

November 17, 2026

Transcript

39 slides
  1. PGConf.Asia 2026 — Tuesday, 17 November 2026 — 17:05–17:35 HKT

    (UTC+8) — Classroom 3 Beyond Vector Search: Graph-Augmented RAG with PostgreSQL SQL/PGQ Koji Annoura Knowledge Graph Architect @kojiannoura [email protected] Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  2. Who Am I? ❖ Koji Annoura ❖ Fukuoka, Japan ❖

    Knowledge Graph Architect ❖ GraphRAG, GQL, SQL/PGQ ❖ Neo4j Ninja ❖ Graph Community MVP Asia 2020 ❖ Co-founder, Neo4j Users Group Tokyo ❖ Founding Chair, JPUG Kyushu (2002)
  3. Today’s Journey ❖ 1. Why Relationships Matter ❖ 2. SQL,

    SQL/PGQ, and GQL ❖ 3. Building Graph-Augmented RAG ❖ 4. PostgreSQL 20 and Beyond
  4. A Change of Plans ❖ Original Plan ❖ SQL/PGQ demo

    in PostgreSQL 19 ❖ What Happened ❖ SQL/PGQ was reverted before release ❖ What We Can Still Explore ❖ SQL/PGQ and GQL standards ❖ Graph queries over relational data ❖ Graph-Augmented RAG Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  5. What Vector Search Does Well ❖ Semantic Search ❖ Finds

    text with similar meaning ❖ Works beyond exact keyword matching ❖ Unstructured Knowledge ❖ Documents, reports, presentations ❖ Questions in natural language ❖ A useful starting point for RAG. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  6. What Vector Search Misses ❖ A relevant document is not

    enough. ❖ Who wrote it? ❖ Author and organization ❖ What is connected to it? ❖ Projects, events, other documents ❖ Can we verify the information? ❖ Sources and supporting evidence ❖ Similarity does not explain relationships. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  7. Knowledge Is Connected ❖ People ❖ Work for companies ❖

    Participate in events ❖ Documents ❖ Have authors and sources ❖ Describe projects and technologies ❖ Organizations ❖ Connect people, projects, and events ❖ Relationships are part of our knowledge. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  8. Relationships Already Exist in SQL ❖ Primary Keys ❖ Identify

    individual records ❖ Foreign Keys ❖ Reference records in other tables ❖ Junction Tables ❖ Represent many-to-many relationships ❖ SQL JOINs ❖ Retrieve data across relationships ❖ Relational databases store connected facts. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  9. Querying Relationships with SQL ❖ Business Question ❖ Which people

    work for companies ❖ participating in PGConf.Asia? ❖ Traditional SQL ❖ Join people with companies ❖ Join companies with event records ❖ Filter by the event ❖ JOINs express the relationships. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  10. When JOINs Become Complicated ❖ Simple Relationships ❖ A few

    JOINs are easy to understand ❖ Multiple Hops ❖ More tables and JOIN conditions ❖ Variable-Length Paths ❖ Recursive CTEs may be required ❖ Long paths make SQL harder to read. ❖ Graph patterns offer another approach. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  11. What Is SQL/PGQ? ❖ SQL Property Graph Queries ❖ Part

    of the SQL:2023 standard ❖ Property Graphs ❖ Vertices and edges over SQL tables ❖ Graph Pattern Matching ❖ Describe connected entities ❖ GRAPH_TABLE ❖ Returns graph query results to SQL ❖ Graph queries become part of SQL. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  12. Defining a Property Graph ❖ CREATE PROPERTY GRAPH ❖ Vertex

    Tables ❖ People, companies, events, documents ❖ Edge Tables ❖ Employment, participation, authorship ❖ Properties ❖ Names, dates, identi ❖ Graph de ers, attributes nitions use existing tables. fi fi Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  13. Querying with GRAPH_TABLE ❖ GRAPH_TABLE ❖ Access a de ned

    property graph ❖ MATCH ❖ Find connected vertices and edges ❖ COLUMNS ❖ Select properties to return ❖ SQL Integration ❖ Use results with WHERE, JOIN, ORDER BY ❖ Graph matching returns relational rows. fi Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  14. SQL JOINs vs. SQL/PGQ ❖ Traditional SQL ❖ Follow foreign

    keys using JOINs ❖ Specify table relationships ❖ SQL/PGQ ❖ Match vertices and edges ❖ Express relationship paths directly ❖ Both query the same relational data. ❖ Different ways to express connections. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  15. SQL vs. SQL/PGQ: The Same Query ❖ SQL ❖ SQL/PGQ

    (Under Development for PostgreSQL)
  16. Multi-Hop Graph Queries ❖ Direct Relationship ❖ Person → Company

    ❖ Multiple Relationships ❖ Person → Company → Event ❖ Path Patterns ❖ Match sequences of vertices and edges ❖ Variable-Length Paths ❖ Follow repeated relationship patterns ❖ Graph queries focus on connected paths. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  17. SQL/PGQ and GQL: Two ISO Standards ❖ SQL/PGQ — ISO/IEC

    9075-16:2023 ❖ Extends SQL with graph queries ❖ Combines graph and relational queries ❖ GQL — ISO/IEC 39075:2024 ❖ A standalone graph database language ❖ Supports graph queries and updates ❖ Shared Foundation ❖ Graph Pattern Matching Language (GPML) ❖ Different roles, common concepts. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  18. A Common Graph Pattern Language ❖ Graph Patterns ❖ Describe

    vertices and relationships ❖ Match connected entities ❖ SQL/PGQ ❖ Uses GRAPH_TABLE within SQL ❖ Returns relational query results ❖ GQL ❖ Uses graph patterns directly ❖ Supports composable graph queries ❖ Shared concepts, different environments. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  19. Graph Query Standards in Real Products ❖ Oracle Database ❖

    SQL/PGQ with GRAPH_TABLE ❖ Google Spanner Graph and BigQuery Graph ❖ Features based on SQL/PGQ and GQL ❖ Neo4j ❖ Cypher with growing GQL compatibility ❖ Ultipa GQLDB ❖ GQL-oriented graph queries ❖ Standards adoption is growing. ❖ Support varies across products. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  20. A Small Enterprise Knowledge Graph ❖ Contacts ❖ People and

    their organizations ❖ Companies ❖ Employers and event participation ❖ Events ❖ Conferences and participants ❖ Documents ❖ Authors, topics, and original sources ❖ All data is stored in PostgreSQL tables. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  21. Finding Documents with pgvector ❖ Question ❖ Who from participating

    companies ❖ has written about GraphRAG? ❖ Vector Search ❖ Find documents related to GraphRAG ❖ Rank results by semantic similarity ❖ Retrieved Information ❖ Document IDs, titles, and text ❖ Similarity scores ❖ Relevant documents, but not the full answer. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  22. Vector Similarity Search with pgvector ❖ Vector Search ❖ Find

    documents with similar meaning ❖ Cosine Distance ❖ Use the <=> operator to rank documents ❖ Top-K Results ❖ Return the ve closest documents ❖ SQL Integration fi ❖ Use vector search directly in PostgreSQL
  23. Connecting Documents to Entities ❖ Start with a Retrieved Document

    ❖ Identify its author ❖ Follow Existing Relationships ❖ Author → Company ❖ Company → Event Participation ❖ Apply the Business Question ❖ Is the company at PGConf.Asia? ❖ Documents become connected to context. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  24. Exploring Relationships with SQL/PGQ ❖ Input ❖ Document IDs from

    vector search ❖ Graph Pattern ❖ Document → Author → Company → Event ❖ Conditions ❖ Event = PGConf.Asia ❖ Document topic = GraphRAG ❖ Output ❖ People, companies, and documents ❖ Relationships and source references Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  25. Combining Vector and Graph Search ❖ Question ❖ Who from

    participating companies has written about GraphRAG? ❖ Vector Search ❖ Find relevant documents using pgvector ❖ Graph Traversal ❖ Connect documents to authors, companies, and events ❖ Combined Results ❖ Relevant documents and connected entities ❖ Supporting evidence and source links Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  26. Combining Three Query Methods ❖ Vector Search ❖ Which documents

    are relevant? ❖ Graph Traversal ❖ How are the documents connected? ❖ SQL ❖ Which results meet our conditions? ❖ Combined Retrieval ❖ Relevant text and connected entities ❖ Relationships and supporting sources ❖ Each method answers a different question. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  27. Keeping Evidence and Provenance ❖ Retrieved Facts ❖ People, companies,

    and events ❖ Supporting Evidence ❖ Documents and original records ❖ Provenance ❖ How the information was created ❖ Traceability ❖ How results link back to sources ❖ Answers should be linked to evidence. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  28. From Retrieved Context to an Answer ❖ Vector RAG Context

    ❖ Relevant document excerpts ❖ Graph-Augmented Context ❖ Documents and connected entities ❖ Relationships and supporting sources ❖ LLM Response ❖ Uses the combined context ❖ Can cite retrieved evidence ❖ Context should be relevant and veri able. fi Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  29. Graph-Augmented RAG Architecture ❖ PostgreSQL ❖ Relational tables and document

    text ❖ Vector embeddings with pgvector ❖ Property graph de nitions ❖ Retrieval ❖ Semantic similarity search ❖ Graph pattern matching ❖ SQL ltering and aggregation ❖ Generation ❖ LLM uses connected context and sources ❖ One data platform, multiple query methods. fi fi Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  30. GraphScan and PostgreSQL 20 ❖ Native Planner and Executor for

    SQL/PGQ ❖ Proposed by Henri Gasc ❖ Reviewed by PostgreSQL contributors ❖ GraphScan Approach ❖ Native graph query execution ❖ Graph-aware planning ❖ Current Development ❖ Targeting PostgreSQL 20 ❖ Patch under review ❖ Further work is required ❖ Inclusion in PostgreSQL 20 is not con rmed. fi Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  31. From Relevant Text to Connected Knowledge ❖ Vector Search ❖

    Finds semantically similar information ❖ SQL ❖ Queries and combines structured data ❖ SQL/PGQ and GQL ❖ Make graph relationships explicit ❖ Graph-Augmented RAG ❖ Combines documents with connected facts ❖ Preserves context and supporting evidence ❖ Knowledge is more than text. ❖ Relationships give it context. Source: Conceptual illustration prepared with OpenAI tools for Koji Annoura, 2026.
  32. Key Takeaway ❖ Vector Search nds relevant information. ❖ SQL

    connects structured data. ❖ SQL/PGQ expresses graph relationships. ❖ GQL brings graph queries into a common standard. fi ❖ Graph-Augmented RAG combines content and context.

More Decks by Koji Annoura

Other Decks in Programming