Skip to main content

max / makenotwork

1.0 KB · 20 lines History Blame Raw
1 -- no-transaction
2 --
3 -- GIN index behind the lexical tier of discover search. Column added in 176.
4 --
5 -- Alone in its file, and the file leads with `-- no-transaction`. Both are
6 -- required: sqlx-core 0.8 opts the migration out of its own transaction by
7 -- matching those exact leading bytes, and Postgres additionally wraps any
8 -- multi-statement simple query in an implicit transaction, which
9 -- CREATE INDEX CONCURRENTLY also refuses. One statement, no transaction.
10 --
11 -- Worth being straight about what CONCURRENTLY buys here: on its own, little.
12 -- 176 already rewrote `items` under ACCESS EXCLUSIVE to add the generated
13 -- column, so the write stall the hygiene guard exists to prevent has already
14 -- happened by the time this runs. Building concurrently is still correct and
15 -- costs nothing, but the migration pair is only cheap because the catalog is
16 -- small. See the note at the top of 176 before re-running either at scale.
17
18 CREATE INDEX CONCURRENTLY IF NOT EXISTS idx_items_search_tsv
19 ON items USING GIN (search_tsv);
20