Files
lobehub/packages/database/migrations/0026_add_autovacuum_tuning.sql
Arvin Xu af1f71572f ♻️ refactor: move database to packages (#8874)
* move db

* refactor db import

* refactor eval types

* fix tests

* fix tests

* fix tests

* fix db migration issues

* fix docker issue

* fix tests

* update alias

* fix tests

* update db test for client and server

* refactor db

* update codecov

* update codecov

* update codecov

* add docker pr comments
2025-08-22 11:09:03 +08:00

15 lines
717 B
SQL

-- Migration to apply specific autovacuum settings to high-traffic tables
-- This is crucial to prevent table and TOAST bloat for 'embeddings' and 'chunks'
-- https://github.com/lobehub/lobe-chat/issues/8316
-- Tuning for the 'embeddings' table
-- Default scale factor (0.2) is too high, leading to infrequent vacuuming.
-- Lowering to 2% to ensure frequent cleanup.
ALTER TABLE "embeddings" SET (autovacuum_vacuum_scale_factor = 0.02, autovacuum_vacuum_threshold = 1000);
--> statement-breakpoint
-- Tuning for the 'chunks' table
-- This table also experiences many updates/deletes and requires similar tuning.
ALTER TABLE "chunks" SET (autovacuum_vacuum_scale_factor = 0.02, autovacuum_vacuum_threshold = 1000);