19 lines
1.3 KiB
SQL
19 lines
1.3 KiB
SQL
-- 运维手动索引步骤:对已发布 research schema 执行,不能由只读服务角色调用,也不能包进事务。
|
|
-- 不属于 db/ 版本迁移;CREATE INDEX CONCURRENTLY 需要独立顶层语句,避免长时间阻塞语料读取。
|
|
-- Manual operator step against the published Paper Atlas schema, outside a
|
|
-- transaction. Core's SELECT-only runtime role must never execute this file.
|
|
-- These indexes support the actual author search and exact category filter;
|
|
-- the migration already owns the title/abstract English GIN index.
|
|
SET lock_timeout = '2s';
|
|
SET statement_timeout = '20min';
|
|
SET maintenance_work_mem = '32MB';
|
|
SET max_parallel_maintenance_workers = 0;
|
|
-- (tag_id,paper_id) 支持纯主题页直接走关联索引,在 LIMIT 前避免读所有宽论文行。
|
|
CREATE INDEX CONCURRENTLY IF NOT EXISTS paper_tags_tag_paper
|
|
ON research.paper_tags(tag_id,paper_id);
|
|
-- simple 配置匹配作者查询的表达式,不对姓名做 english 词干化;索引表达式须与查询一致。
|
|
CREATE INDEX CONCURRENTLY IF NOT EXISTS papers_authors_search_gin
|
|
ON research.papers USING gin(to_tsvector('simple'::regconfig,authors_json));
|
|
-- After an interrupted concurrent build, inspect pg_index.indisvalid before
|
|
-- reuse. IF NOT EXISTS alone does not repair an invalid index.
|