migrations: add documents.tsv_search_tokens

Rather than storing the tsvector data for name, path, synopsis and readme
separately, they will now to be stored together in a tsv_search_tokens,
which has been shown to improve performance for the search query.

Change-Id: I80460b3a9e22efbe642419e37b95e10ed2c73d9f
Reviewed-on: https://team-review.git.corp.google.com/c/golang/discovery/+/455288
Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
Julie Qiu 2019-04-27 14:10:51 -04:00
Родитель f1880ff549
Коммит 2e1a49407d
2 изменённых файлов: 25 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,9 @@
-- Copyright 2019 The Go Authors. All rights reserved.
-- Use of this source code is governed by a BSD-style
-- license that can be found in the LICENSE file.
BEGIN;
ALTER TABLE documents DROP COLUMN tsv_search_tokens;
END;

Просмотреть файл

@ -0,0 +1,16 @@
-- Copyright 2019 The Go Authors. All rights reserved.
-- Use of this source code is governed by a BSD-style
-- license that can be found in the LICENSE file.
BEGIN;
ALTER TABLE documents ADD COLUMN tsv_search_tokens tsvector;
CREATE INDEX tsv_search_tokens_idx ON documents USING gin(tsv_search_tokens);
UPDATE documents SET tsv_search_tokens =
name_tokens ||
path_tokens ||
synopsis_tokens ||
readme_tokens;
END;