RAG-Native AI Database

HeliosDB Full serves the retrieval side of RAG applications through its HTTP gateway: it ingests and searches documents, keeps texts in vector stores with embeddings from a configured AI provider, runs hybrid vector-and-keyword search and serves chat completions through that provider. SQL vector indexes, hybrid search as a SQL function and natural-language-to-SQL are planned, so the SQL examples on this page describe the planned surface.

Planned: SQL vector indexes, SQL search and RAG functions and natural-language-to-SQL are on the roadmap; use the HTTP gateway's document, vector-store and chat routes today. Read the documentation.

Problem Being Solved

Root Cause: AI capabilities (embeddings, vector search, RAG) were built as separate products:

  • Vector Database Silos: Pinecone, Weaviate, Milvus store vectors separately from relational data
  • External Embedding Services: Must call OpenAI/Cohere APIs and manage caching externally
  • No Transactional Consistency: Insert to PostgreSQL doesn't guarantee vector index update

HeliosDB Solution: Unified AI Database

Key Capabilities

1. Native Vector Search (HNSW)

-- Create vector column
ALTER TABLE documents ADD COLUMN embedding vector(1536);

-- Create HNSW index for fast similarity search
CREATE INDEX idx_doc_vectors ON documents
USING hnsw(embedding vector_cosine_ops)
WITH (m = 16, ef_construction = 200);

-- Semantic search with metadata filtering
SELECT title, content,
       embedding <=> query_embedding AS distance
FROM documents
WHERE category = 'technical'
ORDER BY embedding <=> query_embedding
LIMIT 10;

2. Automatic Embedding Generation

-- Enable auto-embedding on table
CREATE TRIGGER auto_embed_docs
BEFORE INSERT OR UPDATE ON documents
FOR EACH ROW
EXECUTE FUNCTION heliosdb_auto_embed(
    source_column => 'content',
    target_column => 'embedding',
    model => 'openai/text-embedding-3-small'
);

-- Insert document - embedding generated automatically
INSERT INTO documents (title, content)
VALUES ('HeliosDB Guide', 'HeliosDB is a multi-model database...');
-- Embedding generated in background, zero application code

3. Hybrid Search (Vector + BM25)

-- Hybrid search combining semantic and keyword matching
SELECT * FROM heliosdb_hybrid_search(
    table_name => 'documents',
    query => 'database performance optimization',
    vector_weight => 0.7,
    bm25_weight => 0.3,
    limit => 10
);

4. Native RAG Pipeline

-- Full RAG query in single SQL statement
SELECT heliosdb_rag_query(
    question => 'How do I optimize query performance?',
    context_table => 'documentation',
    embedding_column => 'embedding',
    content_column => 'content',
    llm_model => 'claude-3-sonnet',
    top_k => 5
);

-- Returns AI-generated answer with source citations

5. Natural Language to SQL (NL2SQL)

-- Query database using natural language
SELECT * FROM heliosdb_nl2sql(
    question => 'Show me the top 10 customers by revenue last quarter',
    schema => 'sales'
);

-- Automatically generates and executes:
-- SELECT c.name, SUM(o.total) as revenue
-- FROM customers c JOIN orders o ON c.id = o.customer_id
-- WHERE o.order_date >= DATE_TRUNC('quarter', CURRENT_DATE - INTERVAL '3 months')
-- GROUP BY c.id ORDER BY revenue DESC LIMIT 10;

Concrete Examples

Example 1: AI-Powered Customer Support

After HeliosDB:

-- Setup (one-time, 5 minutes)
CREATE TABLE knowledge_base (
    id SERIAL PRIMARY KEY,
    title TEXT,
    content TEXT,
    category TEXT,
    embedding vector(1536)
);

-- Enable auto-embedding
SELECT heliosdb_enable_auto_embed(
    'knowledge_base', 'content', 'embedding'
);

-- Import existing knowledge base
INSERT INTO knowledge_base (title, content, category)
SELECT title, content, category FROM old_kb;
-- Embeddings generated automatically during import

-- Query for support (single SQL call)
SELECT heliosdb_rag_query(
    question => $ticket_content,
    context_table => 'knowledge_base',
    filter => format('category = %L', $ticket_category),
    llm_model => 'claude-3-sonnet',
    top_k => 5
) AS suggested_response;

Monthly Costs:

Example 2: E-Commerce Product Search

Company Profile: Online retailer with 500K products, 1M daily searches

Challenge: Users expect semantic search ("comfortable shoes for running") not keyword matching

Solution:

-- Product table with embeddings
CREATE TABLE products (
    id SERIAL PRIMARY KEY,
    name TEXT,
    description TEXT,
    category TEXT,
    price DECIMAL,
    embedding vector(1536),
    CONSTRAINT embedding_not_null CHECK (embedding IS NOT NULL)
);

-- Automatic embedding on product changes
CREATE TRIGGER embed_products
AFTER INSERT OR UPDATE ON products
FOR EACH ROW
EXECUTE FUNCTION heliosdb_auto_embed(
    source => 'name || '' '' || description',
    target => 'embedding',
    model => 'openai/text-embedding-3-small'
);

-- Hybrid search API endpoint
CREATE FUNCTION search_products(
    query TEXT,
    max_price DECIMAL DEFAULT NULL,
    category TEXT DEFAULT NULL
) RETURNS TABLE (
    id INT,
    name TEXT,
    price DECIMAL,
    relevance_score FLOAT
) AS $$
    SELECT
        p.id, p.name, p.price,
        heliosdb_hybrid_score(
            p.embedding,
            heliosdb_embed(query),
            p.description,
            query
        ) AS relevance_score
    FROM products p
    WHERE (max_price IS NULL OR p.price <= max_price)
      AND (category IS NULL OR p.category = category)
    ORDER BY relevance_score DESC
    LIMIT 20;
$$ LANGUAGE SQL;

-- Usage
SELECT * FROM search_products(
    'comfortable running shoes for flat feet',
    max_price => 150.00
);

Example 3: Legal Document Intelligence

Company Profile: Law firm with 2M documents, 50 attorneys

Use Case: AI-powered legal research and document retrieval

-- Document storage with metadata and embeddings
CREATE TABLE legal_documents (
    id SERIAL PRIMARY KEY,
    title TEXT,
    content TEXT,
    case_number TEXT,
    practice_area TEXT,
    jurisdiction TEXT,
    date_filed DATE,
    embedding vector(1536),
    chunks JSONB  -- Chunked content for RAG
);

-- Chunking configuration
SELECT heliosdb_configure_chunking(
    table_name => 'legal_documents',
    content_column => 'content',
    strategy => 'semantic',  -- 5 strategies available
    chunk_size => 1000,
    overlap => 200
);

-- Legal research query
SELECT heliosdb_rag_query(
    question => 'What are the key precedents for
                 intellectual property infringement
                 in software licensing disputes?',
    context_table => 'legal_documents',
    filter => 'practice_area = ''IP Law''
               AND jurisdiction IN (''Federal'', ''9th Circuit'')',
    llm_model => 'claude-3-opus',
    top_k => 10,
    include_citations => true
);

-- Returns structured response with:
-- - AI-synthesized answer
-- - Source document citations
-- - Relevance scores
-- - Case numbers for verification

Example 4: Healthcare Clinical Decision Support

Company Profile: Hospital network with 5M patient records

Challenge: Help physicians find relevant clinical guidelines based on patient conditions

-- Clinical knowledge base
CREATE TABLE clinical_guidelines (
    id SERIAL PRIMARY KEY,
    condition TEXT,
    guideline_text TEXT,
    source TEXT,
    last_updated DATE,
    embedding vector(1536)
);

-- Patient-condition matching (HIPAA-compliant)
CREATE FUNCTION get_clinical_recommendations(
    patient_conditions TEXT[],
    medications TEXT[]
) RETURNS TABLE (
    guideline_id INT,
    condition TEXT,
    recommendation TEXT,
    contraindications TEXT[],
    relevance FLOAT
) AS $$
    -- Use differential privacy for patient data
    WITH patient_context AS (
        SELECT heliosdb_embed(
            array_to_string(patient_conditions, ' ') || ' ' ||
            array_to_string(medications, ' ')
        ) AS context_embedding
    )
    SELECT
        cg.id,
        cg.condition,
        heliosdb_rag_answer(
            context => cg.guideline_text,
            question => 'What is the recommended treatment?'
        ),
        heliosdb_extract_contraindications(
            cg.guideline_text,
            medications
        ),
        cg.embedding <=> pc.context_embedding AS relevance
    FROM clinical_guidelines cg, patient_context pc
    ORDER BY relevance
    LIMIT 5;
$$ LANGUAGE SQL;

Compliance:
- HIPAA-compliant (data never leaves database)
- Differential privacy for analytics
- Full audit trail
- Role-based access control

Implementation Roadmap

Quick Start

-- 1. Enable RAG features
SELECT heliosdb_enable_rag();

-- 2. Add embedding column to existing table
ALTER TABLE documents ADD COLUMN embedding vector(1536);

-- 3. Generate embeddings for existing data
SELECT heliosdb_generate_embeddings(
    'documents', 'content', 'embedding',
    model => 'openai/text-embedding-3-small'
);

-- 4. Create vector index
CREATE INDEX idx_doc_embed ON documents
USING hnsw(embedding vector_cosine_ops);

-- 5. Query!
SELECT title, content
FROM documents
ORDER BY embedding <=> heliosdb_embed('your search query')
LIMIT 10;

Production Deployment (Week 1)

Day 1-2: Setup
├── Deploy HeliosDB cluster
├── Configure embedding providers
├── Set up API keys securely
└── Test connectivity

Day 3-4: Data Migration
├── Import existing data
├── Generate embeddings (bulk)
├── Create indexes
└── Validate data integrity

Day 5-7: Integration
├── Update application queries
├── Performance testing
├── Set up monitoring
└── Go live

Conclusion

HeliosDB's RAG-native capabilities eliminate the complexity of building AI applications. By unifying vector search, embedding generation, and RAG pipelines within a single ACID-compliant database, organizations can:

  • Stay Compliant: Data never leaves the database

Performance depends on workload and hardware. Published figures are measured on representative fixtures; see the benchmarks page and reproduce them on your own workload.