Kingbase Banner

Build Decoupled RAG: Secure Metadata and Vector Storage

Precision tools arranged in foam cutouts representing the structured layers of a decoupled RAG architecture

Architecting Decoupled RAG Layers

Designing a robust database for llm applications requires decoupling the transactional system of record from the vector retrieval layer. This architecture ensures that metadata filtering and hybrid search do not compromise ACID compliance or data lineage. KingbaseES serves as a secure, multi-model foundation for enterprise AI pipelines.

A production-grade Retrieval-Augmented Generation (RAG) pipeline relies on three distinct layers. The first layer is the Transactional System of Record. This layer handles structured business data with strict ACID compliance. The second layer is the Vector Retrieval Layer. This layer stores embeddings and executes semantic searches. The third layer is the Orchestration Layer. This layer manages LLM inference and prompt engineering.

Fragmented stacks that separate these layers increase latency and maintenance overhead. Network hops between transactional databases and external vector stores introduce latency. They also complicate data lineage tracking. A unified multi-model architecture reduces these risks. KingbaseES supports a multi-model architecture that handles relational, document, spatial, time series, text, key-value, property graph, and vector embeddings data types within a single system.

This approach treats the database as a secure metadata and vector-hosting layer. It integrates with external orchestration tools while prioritizing data sovereignty. The system maintains transactional integrity for structured data while supporting low-latency vector retrieval.

Setting Up Native Embedding Storage

To configure KingbaseES for vector workloads, start with the correct prerequisites. You need a KingbaseES V8.0 environment with multi-model support enabled. Ensure the server has sufficient memory for vector index caching.

Follow these steps to prepare the environment:

  1. Verify the KingbaseES version is V8.0 or later.
  2. Enable the multi-model extensions required for vector data types.
  3. Create a table with a dedicated column for vector embeddings.
  4. Define the vector dimension size to match your embedding model output.

KingbaseES supports native embedding storage. This allows you to store vectors directly within the database without external plugins. The system handles the serialization and indexing of these vectors.

Indexing for Low-Latency Retrieval

Vector search performance depends on efficient indexing. Standard B-tree indexes do not support vector similarity searches. You must use Approximate Nearest-Neighbor (ANN) indexing for this workload.

Implement ANN indexing as follows:

  1. Create an index on the vector column using the ANN algorithm.
  2. Specify the distance metric, such as cosine or Euclidean distance.
  3. Analyze the table to update statistics for the optimizer.
  4. Execute a sample query to verify index usage.

Note: Specific syntax for creating ANN indexes in KingbaseES varies by version and configuration. Consult the official KingbaseES documentation for the exact command to create vector indexes.

This indexing strategy optimizes vector search performance. It can potentially reduce latency in specific architectures where network hops are eliminated. The system returns relevant documents based on semantic similarity.

Implementing Hybrid Search Logic

Hybrid search combines vector similarity with structured metadata filtering. This approach handles complex queries that require both semantic understanding and precise attribute matching.

Construct a hybrid query using the following pattern:

  1. Filter records by metadata fields to reduce the search space.
  2. Calculate vector similarity for the remaining records.
  3. Rank results by combining metadata relevance and vector distance.

The database applies the metadata filters to reduce the search space. This improves both accuracy and latency. The system returns the top ten most relevant documents that match the specific criteria.

Integrating with LLM Frameworks

Connect KingbaseES to LLM orchestration frameworks like LangChain or LlamaIndex. These frameworks manage the retrieval process and prompt construction.

Configure the integration as follows:

  1. Install the database driver compatible with your framework version.
  2. Define the connection string with the host, port, and credentials.
  3. Initialize the vector store object in your application code.
  4. Test the connection and verify embedding retrieval.

KingbaseES integrates with these frameworks through standard drivers. This allows your application to treat the database as a vector store. The framework handles the embedding generation and query execution. You maintain control over the data storage and security policies.

Validating Retrieval Accuracy

Validate the system to ensure it meets performance and accuracy requirements. Use a test dataset with known relevant documents. Measure the retrieval latency and the relevance of the results.

Perform these verification checks:

  1. Execute a batch of queries against the test dataset.
  2. Record the average latency for vector retrieval.
  3. Calculate the recall rate for the top ten results.
  4. Check the query execution plan for index usage.

The system should return relevant documents within the target latency. The recall rate indicates how often the system finds the correct document. High latency suggests a need for index optimization or hardware scaling.

Securing Enterprise Data with Guomi

Enterprise AI applications require robust security. KingbaseES supports national cryptographic (Guomi) identity authentication mechanisms. This feature aligns with strict security standards for sensitive data.

Configure Guomi authentication as follows:

  1. Enable the Guomi authentication module in the configuration file.
  2. Generate the required cryptographic certificates and keys.
  3. Update the sys_hba.conf to enforce Guomi authentication for specific users.
  4. Reload the configuration using sys_reload_conf().

Note for Overseas Deployments: Guomi authentication is a China-specific security standard. For international deployments (e.g., in Malaysia or Europe), this feature may not be applicable or required for local compliance frameworks such as PDPA or GDPR. Verify if your local regulatory environment mandates specific cryptographic standards before enabling Guomi modules.

This setup ensures that only authorized users can access the vector data. The system encrypts data in transit and at rest using national cryptographic standards. This protects the embeddings and metadata from unauthorized access.

Access Control for Vectors

Restricting access to vector columns is critical for data security. KingbaseES relies on standard database permissions and row-level security features to control access.

  1. Define roles and privileges for users accessing vector data.
  2. Apply row-level security policies to filter data based on user attributes.
  3. Ensure that vector columns are not accessible to unauthorized roles.

This approach ensures that sensitive embeddings are protected. It complements the Guomi authentication layer by enforcing granular access control.

Index Freshness and Update Latency

Vector indexes require regular updates to reflect new data. KingbaseES handles vector updates through standard transactional mechanisms.

  1. Insert or update vector records using standard SQL commands.
  2. Monitor the index rebuild or update process if supported by the specific ANN implementation.
  3. Consider external orchestration for high-frequency updates if native index refresh is not immediate.

If the database does not support real-time index updates, external orchestration may be required to manage index freshness. This ensures that search results remain accurate.

Scaling with RAC Cache Fusion

High-concurrency AI workloads require high availability and scalability. KingbaseES RAC (Shared Storage Cluster) provides these capabilities. It uses cache fusion technology to synchronize data across multiple nodes.

Deploy RAC for your RAG pipeline as follows:

  1. Install KingbaseES on multiple nodes with shared storage access.
  2. Configure the RAC cluster parameters for cache fusion.
  3. Start the RAC services on all nodes.
  4. Verify the multi-active status and data synchronization.

This architecture supports multi-active and multi-write scenarios. It provides high availability by eliminating single points of failure in the cluster configuration. The Qingdao National Health Information Platform used KingbaseES V8.0 to support high-concurrency diagnosis and medical collaboration. FAW used KingbaseES to reduce query response from seconds to milliseconds. These cases demonstrate the system’s ability to handle demanding enterprise workloads.

Rollback Procedures

If vector index creation or configuration changes fail, follow these rollback steps:

  1. Drop the failed vector index using the standard DROP INDEX command.
  2. Revert sys_hba.conf changes to the previous stable configuration.
  3. Reload the configuration using sys_reload_conf() to apply the rollback.
  4. Verify that the database returns to its previous operational state.

Verification Checklist

Use this checklist to confirm the deployment meets technical requirements:

  • ACID Compliance: Verify that transactional operations maintain consistency.
  • Vector Retrieval Latency: Measure latency against benchmarks; note that specific benchmarks are not provided in this guide.
  • Metadata Filtering: Confirm that metadata filters reduce the search space effectively.
  • Index Freshness: Ensure that vector updates are reflected in search results.
  • Access Control: Verify that only authorized users can access vector data.

FAQ

What are the key technical criteria for selecting KingbaseES for LLM applications?

Select KingbaseES for its multi-model architecture, native embedding storage, and ANN indexing. Verify support for Guomi authentication and integration with orchestration frameworks.

How does KingbaseES’s multi-model architecture impact retrieval latency in RAG systems?

The multi-model architecture can potentially reduce latency in specific architectures where network hops are eliminated by storing vectors and metadata in the same system.

What are the trade-offs between using KingbaseES RAC and self-hosted solutions for high-concurrency AI workloads?

KingbaseES RAC provides multi-active capabilities and cache fusion for high availability. Self-hosted solutions may offer more flexibility but require more manual maintenance. RAC ensures data consistency across nodes.

How to ensure data security and compliance (e.g., Guomi) when storing embeddings in KingbaseES?

Enable Guomi identity authentication and configure access controls in sys_hba.conf. Use the database’s built-in encryption features to protect data at rest and in transit. Note that Guomi is a China-specific standard and may not be required for international compliance.

What are the common failure modes in vector database integration for AI, and how does KingbaseES mitigate them?

Common failures include index corruption and high latency. KingbaseES mitigates these through robust ACID compliance, native ANN indexing, and RAC-based high availability.

Related reading


💡 More Resources

If you would like to dive deeper into KingbaseES and its application practices across various industries, we have compiled the following official resources to help you get started quickly and develop and operate with efficiency:

  • Kingbase Community: A one-stop interactive platform for technical exchanges, Q&A, and experience sharing—join forces with fellow DBAs and developers.
  • Kingbase Solutions: One-stop full-stack database migration and cloud-native solutions, supporting smooth migration of multi-source heterogeneous data, ensuring high availability, real-time integration, and sustained high performance.
  • Kingbase Case Studies: Real-world user scenarios and implementation outcomes, showcasing KingbaseES’s outstanding capabilities in high availability, high performance, and IT adaptation.
  • Kingbase Documentation: Authoritative and comprehensive product manuals and technical guides, covering the entire lifecycle from installation and deployment to development, programming, and operations management.
  • Free Download: Get the latest installation packages, drivers, tools, and patches, supporting multiple platforms and domestic chip architectures.
  • Digital Construction Encyclopedia: Covers digital strategy planning, data integration, metrics management, database visualization applications, and more to empower enterprise digital transformation.

Open Source Resources:

Welcome to explore the resources above and begin your Kingbase journey!