From 6bac54b555d27f1a85c1e4f011a6e7bd9111b0d0 Mon Sep 17 00:00:00 2001
From: rudb <office@database.ru>
Date: Tue, 06 Oct 2026 02:35:45 +0000
Subject: [PATCH] СУБД RuDB - релиз 3
---
src/backend/utils/misc/guc_tables.c | 253 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 253 insertions(+), 0 deletions(-)
diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c
index 982d69b..360c419 100644
--- a/src/backend/utils/misc/guc_tables.c
+++ b/src/backend/utils/misc/guc_tables.c
@@ -105,6 +105,10 @@
#include "utils/xml.h"
#include "access/tempcat.h"
+#include "vector/hnsw.h"
+#include "vector/ivfflat.h"
+#include "vectorizer/pgedge_vectorizer.h"
+
#ifdef TRACE_SYNCSCAN
#include "access/syncscan.h"
#endif
@@ -2175,6 +2179,28 @@
NULL, NULL, NULL
},
+ {
+ {"rudb_ai.auto_chunk", PGC_SIGHUP, CUSTOM_OPTIONS,
+ "Enable automatic chunking",
+ "Automatically chunk documents when enabled via enable_vectorization().",
+ 0
+ },
+ &pgedge_vectorizer_auto_chunk,
+ true,
+ NULL, NULL, NULL
+ },
+
+ {
+ {"rudb_ai.strip_non_ascii", PGC_SIGHUP, CUSTOM_OPTIONS,
+ "Strip non-ASCII characters from chunks",
+ "Remove non-ASCII characters (like box-drawing, emoji, etc.) that may cause API issues.",
+ 0
+ },
+ &pgedge_vectorizer_strip_non_ascii,
+ true,
+ NULL, NULL, NULL
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL, NULL
@@ -3903,6 +3929,132 @@
// NULL, NULL, NULL
// },
+ {
+ {"hnsw.ef_search", PGC_USERSET, CUSTOM_OPTIONS,
+ "Sets the size of the dynamic candidate list for search",
+ "Valid range is 1..1000.",
+ 0, PGC_INT
+ },
+ &hnsw_ef_search,
+ HNSW_DEFAULT_EF_CONSTRUCTION, HNSW_MIN_EF_SEARCH, HNSW_MAX_EF_SEARCH,
+ NULL, NULL, NULL
+ },
+
+ {
+ {"hnsw.max_scan_tuples", PGC_USERSET, CUSTOM_OPTIONS,
+ "Sets the max number of tuples to visit for iterative scans",
+ NULL,
+ 0, PGC_INT
+ },
+ &hnsw_max_scan_tuples,
+ 20000, 1, INT_MAX,
+ NULL, NULL, NULL
+ },
+
+ {
+ {"ivfflat.probes", PGC_USERSET, CUSTOM_OPTIONS,
+ "Sets the number of probes",
+ "Valid range is 1..lists.",
+ 0, PGC_INT
+ },
+ &ivfflat_probes,
+ IVFFLAT_DEFAULT_PROBES, IVFFLAT_MIN_LISTS, IVFFLAT_MAX_LISTS,
+ NULL, NULL, NULL
+ },
+
+ {
+ {"ivfflat.max_probes", PGC_USERSET, CUSTOM_OPTIONS,
+ "Sets the max number of probes for iterative scans",
+ NULL,
+ 0, PGC_INT
+ },
+ &ivfflat_max_probes,
+ IVFFLAT_MAX_LISTS, IVFFLAT_MIN_LISTS, IVFFLAT_MAX_LISTS,
+ NULL, NULL, NULL
+ },
+
+ {
+ {"rudb_ai.num_workers", PGC_POSTMASTER, CUSTOM_OPTIONS,
+ "Number of background workers",
+ "Number of background worker processes to spawn. "
+ "Requires PostgreSQL restart to change.",
+ 0
+ },
+ &pgedge_vectorizer_num_workers,
+ 2, 1, 32,
+ NULL, NULL, NULL
+ },
+
+ {
+ {"rudb_ai.batch_size", PGC_SIGHUP, CUSTOM_OPTIONS,
+ "Batch size for embedding generation",
+ "Number of text chunks to process in a single API call. "
+ "Larger batches are more efficient but require more memory.",
+ 0
+ },
+ &pgedge_vectorizer_batch_size,
+ 10, 1, 100,
+ NULL, NULL, NULL
+ },
+
+ {
+ {"rudb_ai.max_retries", PGC_SIGHUP, CUSTOM_OPTIONS,
+ "Maximum retry attempts for failed embeddings",
+ "Number of times to retry generating embeddings on failure. "
+ "Uses exponential backoff.",
+ 0
+ },
+ &pgedge_vectorizer_max_retries,
+ 3, 0, 10,
+ NULL, NULL, NULL
+ },
+
+ {
+ {"rudb_ai.worker_poll_interval", PGC_SIGHUP, CUSTOM_OPTIONS,
+ "Worker polling interval in milliseconds",
+ "How often workers check for new work when idle.",
+ 0
+ },
+ &pgedge_vectorizer_worker_poll_interval,
+ 1000, 100, 60000,
+ NULL, NULL, NULL
+ },
+
+ {
+ {"rudb_ai.default_chunk_size", PGC_SIGHUP, CUSTOM_OPTIONS,
+ "Default chunk size in tokens",
+ "Target size for each chunk in tokens.",
+ 0
+ },
+ &pgedge_vectorizer_default_chunk_size,
+ 400, 50, 2000,
+ NULL, NULL, NULL
+ },
+
+ {
+ {"rudb_ai.default_chunk_overlap", PGC_SIGHUP, CUSTOM_OPTIONS,
+ "Default chunk overlap in tokens",
+ "Number of tokens to overlap between consecutive chunks.",
+ 0
+ },
+ &pgedge_vectorizer_default_chunk_overlap,
+ 50, 0, 500,
+ NULL, NULL, NULL
+ },
+
+ {
+ {"rudb_ai.auto_cleanup_hours", PGC_SIGHUP, CUSTOM_OPTIONS,
+ "Automatically clean up completed queue items older than this many hours",
+ "Workers will periodically delete completed items older than this value. "
+ "Set to 0 to disable automatic cleanup.",
+ 0
+ },
+ &pgedge_vectorizer_auto_cleanup_hours,
+ 24, 0, 8760,
+ NULL, NULL, NULL
+ },
+
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, 0, 0, 0, NULL, NULL, NULL
@@ -4194,6 +4346,15 @@
NULL, NULL, NULL
},
+ {
+ {"hnsw.scan_mem_multiplier", PGC_USERSET, CUSTOM_OPTIONS,
+ "Sets the multiple of work_mem to use for iterative scans",
+ NULL,
+ },
+ &hnsw_scan_mem_multiplier,
+ 1., 1., 1000.
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, 0.0, 0.0, 0.0, NULL, NULL, NULL
@@ -5038,6 +5199,78 @@
check_log_connections, assign_log_connections, NULL
},
+ {
+ {"rudb_ai.provider", PGC_USERSET, CUSTOM_OPTIONS,
+ "Embedding provider to use (openai, voyage, ollama)",
+ "Determines which API provider is used for generating embeddings.",
+ 0
+ },
+ &pgedge_vectorizer_provider,
+ "openai",
+ NULL, NULL, NULL
+ },
+
+ {
+ {"rudb_ai.api_key_file", PGC_USERSET, CUSTOM_OPTIONS,
+ "Path to file containing API key",
+ "File should contain only the API key, one line. "
+ "Tilde (~) expands to home directory.",
+ 0
+ },
+ &pgedge_vectorizer_api_key_file,
+ "~/.pgedge-vectorizer-llm-api-key",
+ NULL, NULL, NULL
+ },
+
+ {
+ {"rudb_ai.api_url", PGC_USERSET, CUSTOM_OPTIONS,
+ "API endpoint URL",
+ "API endpoint URL. Defaults: OpenAI=https://api.openai.com/v1, "
+ "Voyage=https://api.voyageai.com/v1, Ollama=http://localhost:11434",
+ 0
+ },
+ &pgedge_vectorizer_api_url,
+ "https://api.openai.com/v1",
+ NULL, NULL, NULL
+ },
+
+ {
+ {"rudb_ai.model", PGC_USERSET, CUSTOM_OPTIONS,
+ "Embedding model name",
+ "Model to use for embeddings. Examples: "
+ "OpenAI: text-embedding-3-small, text-embedding-3-large; "
+ "Voyage: voyage-2, voyage-large-2, voyage-code-2; "
+ "Ollama: nomic-embed-text, mxbai-embed-large",
+ 0
+ },
+ &pgedge_vectorizer_model,
+ "text-embedding-3-small",
+ NULL, NULL, NULL
+ },
+
+ {
+ {"rudb_ai.databases", PGC_SIGHUP, CUSTOM_OPTIONS,
+ "Comma-separated list of databases to monitor",
+ "List of database names where the extension should process embeddings. "
+ "If not set, workers will not connect to any database.",
+ 0
+ },
+ &pgedge_vectorizer_databases,
+ "",
+ NULL, NULL, NULL
+ },
+
+ {
+ {"rudb_ai.default_chunk_strategy", PGC_SIGHUP, CUSTOM_OPTIONS,
+ "Default chunking strategy",
+ "Strategy to use for chunking: token_based, semantic, markdown, sentence.",
+ 0
+ },
+ &pgedge_vectorizer_default_chunk_strategy,
+ "token_based",
+ NULL, NULL, NULL
+ },
+
/* End-of-list marker */
{
@@ -5482,6 +5715,26 @@
NULL, assign_io_method, NULL
},
+ {
+ {"hnsw.iterative_scan", PGC_USERSET, CUSTOM_OPTIONS,
+ "Sets the mode for iterative scans",
+ NULL
+ },
+ &hnsw_iterative_scan,
+ HNSW_ITERATIVE_SCAN_OFF, hnsw_iterative_scan_options,
+ NULL, NULL, NULL
+ },
+
+ {
+ {"ivfflat.iterative_scan", PGC_USERSET, CUSTOM_OPTIONS,
+ "Sets the mode for iterative scans",
+ NULL
+ },
+ &ivfflat_iterative_scan,
+ IVFFLAT_ITERATIVE_SCAN_OFF, ivfflat_iterative_scan_options,
+ NULL, NULL, NULL
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, 0, NULL, NULL, NULL, NULL
--
Gitblit v1.10.0