mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
Report progress of CREATE INDEX operations
This uses the progress reporting infrastructure added by c16dc1aca5
,
adding support for CREATE INDEX and CREATE INDEX CONCURRENTLY.
There are two pieces to this: one is index-AM-agnostic, and the other is
AM-specific. The latter is fairly elaborate for btrees, including
reportage for parallel index builds and the separate phases that btree
index creation uses; other index AMs, which are much simpler in their
building procedures, have simplistic reporting only, but that seems
sufficient, at least for non-concurrent builds.
The index-AM-agnostic part is fairly complete, providing insight into
the CONCURRENTLY wait phases as well as block-based progress during the
index validation table scan. (The index validation index scan requires
patching each AM, which has not been included here.)
Reviewers: Rahila Syed, Pavan Deolasee, Tatsuro Yamada
Discussion: https://postgr.es/m/20181220220022.mg63bhk26zdpvmcj@alvherre.pgsql
This commit is contained in:
@@ -23,9 +23,11 @@
|
||||
#include "access/relscan.h"
|
||||
#include "access/tableam.h"
|
||||
#include "catalog/index.h"
|
||||
#include "commands/progress.h"
|
||||
#include "commands/vacuum.h"
|
||||
#include "miscadmin.h"
|
||||
#include "optimizer/plancat.h"
|
||||
#include "pgstat.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/index_selfuncs.h"
|
||||
#include "utils/rel.h"
|
||||
@@ -83,6 +85,7 @@ hashhandler(PG_FUNCTION_ARGS)
|
||||
amroutine->amcostestimate = hashcostestimate;
|
||||
amroutine->amoptions = hashoptions;
|
||||
amroutine->amproperty = NULL;
|
||||
amroutine->ambuildphasename = NULL;
|
||||
amroutine->amvalidate = hashvalidate;
|
||||
amroutine->ambeginscan = hashbeginscan;
|
||||
amroutine->amrescan = hashrescan;
|
||||
@@ -160,9 +163,11 @@ hashbuild(Relation heap, Relation index, IndexInfo *indexInfo)
|
||||
buildstate.heapRel = heap;
|
||||
|
||||
/* do the heap scan */
|
||||
reltuples = table_index_build_scan(heap, index, indexInfo, true,
|
||||
reltuples = table_index_build_scan(heap, index, indexInfo, true, true,
|
||||
hashbuildCallback,
|
||||
(void *) &buildstate, NULL);
|
||||
pgstat_progress_update_param(PROGRESS_CREATEIDX_TUPLES_TOTAL,
|
||||
buildstate.indtuples);
|
||||
|
||||
if (buildstate.spool)
|
||||
{
|
||||
|
@@ -26,7 +26,9 @@
|
||||
#include "postgres.h"
|
||||
|
||||
#include "access/hash.h"
|
||||
#include "commands/progress.h"
|
||||
#include "miscadmin.h"
|
||||
#include "pgstat.h"
|
||||
#include "utils/tuplesort.h"
|
||||
|
||||
|
||||
@@ -116,6 +118,7 @@ void
|
||||
_h_indexbuild(HSpool *hspool, Relation heapRel)
|
||||
{
|
||||
IndexTuple itup;
|
||||
long tups_done = 0;
|
||||
#ifdef USE_ASSERT_CHECKING
|
||||
uint32 hashkey = 0;
|
||||
#endif
|
||||
@@ -141,5 +144,8 @@ _h_indexbuild(HSpool *hspool, Relation heapRel)
|
||||
#endif
|
||||
|
||||
_hash_doinsert(hspool->index, itup, heapRel);
|
||||
|
||||
pgstat_progress_update_param(PROGRESS_CREATEIDX_TUPLES_DONE,
|
||||
++tups_done);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user