pgsql: Avoid spurious waits in concurrent indexing

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема pgsql: Avoid spurious waits in concurrent indexing
Дата
Msg-id E1ki2Gt-00057q-D8@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Avoid spurious waits in concurrent indexing

In the various waiting phases of CREATE INDEX CONCURRENTLY (CIC) and
REINDEX CONCURRENTLY (RC), we wait for other processes to release their
snapshots; this is necessary in general for correctness.  However,
processes doing CIC in other tables cannot possibly affect CIC or RC
done in "this" table, so we don't need to wait for those.  This commit
adds a flag in MyProc->statusFlags to indicate that the current process
is doing CIC, so that other processes doing CIC or RC can ignore it when
waiting.

Note that this logic is only valid if the index does not access other
tables.  For simplicity we avoid setting the flag if the index has a
column that's an expression, or has a WHERE predicate.  (It is possible
to have expressional or partial indexes that do not access other tables,
but figuring that out would require more work.)

This flag can potentially also be used by processes doing REINDEX
CONCURRENTLY to be skipped; and by VACUUM to ignore processes in CIC or
RC for the purposes of computing an Xmin.  That's left for future
commits.

Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Author: Dimitry Dolgov <9erthalion6@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/20200810233815.GA18970@alvherre.pgsql

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c98763bf51bf610b3ee7e209fc76c3ff9a6b3163

Modified Files
--------------
src/backend/commands/indexcmds.c | 63 ++++++++++++++++++++++++++++++++++++++--
src/include/storage/proc.h       |  5 +++-
2 files changed, 64 insertions(+), 4 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: In psql's \d commands, don't truncate attribute default values.
Следующее
От: Amit Kapila
Дата:
Сообщение: pgsql: Use Enums for logical replication message types at more places.