> For the complete documentation index, see [llms.txt](https://docs.veriscript.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.veriscript.app/01-installation-guide/03-database-and-corpus.md). Agents can also search and read this documentation through its [MCP server](https://docs.veriscript.app/~gitbook/mcp).

# 03 database and corpus

## ⚙️ ปรับจูน `postgresql.conf` สำหรับ 128 GB Unified Memory

สร้างไฟล์ `/opt/veriscript/config/postgresql.conf` ด้วยค่าพารามิเตอร์ที่เหมาะสมกับดัชนี HNSW:

```ini
listen_addresses = '*'
max_connections = 200
shared_buffers = 16GB
effective_cache_size = 48GB
work_mem = 64MB
maintenance_work_mem = 4GB
random_page_cost = 1.1
effective_io_concurrency = 200
max_parallel_workers_per_gather = 4
```

## 📦 การเตรียมฐานข้อมูลตามแพ็กเกจที่จัดซื้อ

{% tabs %}
{% tab title="🟢 แพ็กเกจ A: OEM Standard (ฐานข้อมูลว่าง)" %}
สำหรับลูกค้าที่จัดซื้อ **แพ็กเกจ A (Software Engine Only)** ระบบจะสร้างตารางฐานข้อมูลเปล่าพร้อมเปิดใช้งานส่วนขยาย `pgvector` อัตโนมัติเมื่อรัน Docker Compose:

```sql
CREATE EXTENSION IF NOT EXISTS vector;
```

ผู้ดูแลระบบขององค์กรสามารถนำเข้าเอกสารภายใน (PDF/DOCX) ผ่านหน้า **Admin → Private Corpus** ได้ทันที
{% endtab %}

{% tab title="⭐ แพ็กเกจ B: National Corpus (1.47 ล้านเล่ม)" %}
สำหรับลูกค้าที่จัดซื้อ **แพ็กเกจ B** ให้ตรวจสอบความสมบูรณ์ของไฟล์ดัชนีด้วย SHA-256 แล้วนำเข้าสู่ฐานข้อมูล:

```bash
# 1. ตรวจสอบ SHA-256 Checksum
sha256sum -c /opt/veriscript/backups/veriscript_national_index_v2.dump.sha256

# 2. นำเข้าดัชนีเวกเตอร์ 768 มิติแบบขนาน (4 Jobs)
docker exec -i veriscript-pgvector pg_restore \
  -U veriscript_admin \
  -d veriscript \
  --no-owner --jobs=4 < /opt/veriscript/backups/veriscript_national_index_v2.dump

# 3. ตรวจสอบยอดสะสมระเบียน (ต้องได้ 1,472,405+ รายการ)
docker exec -it veriscript-pgvector psql -U veriscript_admin -d veriscript -c \
  "SELECT COUNT(*) AS total_records FROM public.national_research;"
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.veriscript.app/01-installation-guide/03-database-and-corpus.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
