Skip to content

Commit 5262f7a

Browse files
committed
Add optimizer and executor support for parallel index scans.
In combination with 569174f, which taught the btree AM how to perform parallel index scans, this allows parallel index scan plans on btree indexes. This infrastructure should be general enough to support parallel index scans for other index AMs as well, if someone updates them to support parallel scans. Amit Kapila, reviewed and tested by Anastasia Lubennikova, Tushar Ahuja, and Haribabu Kommi, and me.
1 parent 51ee6f3 commit 5262f7a

File tree

29 files changed

+366
-55
lines changed

29 files changed

+366
-55
lines changed

contrib/bloom/blcost.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
void
2525
blcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
2626
Cost *indexStartupCost, Cost *indexTotalCost,
27-
Selectivity *indexSelectivity, double *indexCorrelation)
27+
Selectivity *indexSelectivity, double *indexCorrelation,
28+
double *indexPages)
2829
{
2930
IndexOptInfo *index = path->indexinfo;
3031
List *qinfos;
@@ -45,4 +46,5 @@ blcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
4546
*indexTotalCost = costs.indexTotalCost;
4647
*indexSelectivity = costs.indexSelectivity;
4748
*indexCorrelation = costs.indexCorrelation;
49+
*indexPages = costs.numIndexPages;
4850
}

contrib/bloom/bloom.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,6 @@ extern bytea *bloptions(Datum reloptions, bool validate);
208208
extern void blcostestimate(PlannerInfo *root, IndexPath *path,
209209
double loop_count, Cost *indexStartupCost,
210210
Cost *indexTotalCost, Selectivity *indexSelectivity,
211-
double *indexCorrelation);
211+
double *indexCorrelation, double *indexPages);
212212

213213
#endif

contrib/bloom/blutils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ blhandler(PG_FUNCTION_ARGS)
119119
amroutine->amstorage = false;
120120
amroutine->amclusterable = false;
121121
amroutine->ampredlocks = false;
122+
amroutine->amcanparallel = false;
122123
amroutine->amkeytype = InvalidOid;
123124

124125
amroutine->ambuild = blbuild;

doc/src/sgml/indexam.sgml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ typedef struct IndexAmRoutine
110110
bool amclusterable;
111111
/* does AM handle predicate locks? */
112112
bool ampredlocks;
113+
/* does AM support parallel scan? */
114+
bool amcanparallel;
113115
/* type of data stored in index, or InvalidOid if variable */
114116
Oid amkeytype;
115117

src/backend/access/brin/brin.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ brinhandler(PG_FUNCTION_ARGS)
9393
amroutine->amstorage = true;
9494
amroutine->amclusterable = false;
9595
amroutine->ampredlocks = false;
96+
amroutine->amcanparallel = false;
9697
amroutine->amkeytype = InvalidOid;
9798

9899
amroutine->ambuild = brinbuild;

src/backend/access/gin/ginutil.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ ginhandler(PG_FUNCTION_ARGS)
5050
amroutine->amstorage = true;
5151
amroutine->amclusterable = false;
5252
amroutine->ampredlocks = false;
53+
amroutine->amcanparallel = false;
5354
amroutine->amkeytype = InvalidOid;
5455

5556
amroutine->ambuild = ginbuild;

src/backend/access/gist/gist.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ gisthandler(PG_FUNCTION_ARGS)
7171
amroutine->amstorage = true;
7272
amroutine->amclusterable = true;
7373
amroutine->ampredlocks = false;
74+
amroutine->amcanparallel = false;
7475
amroutine->amkeytype = InvalidOid;
7576

7677
amroutine->ambuild = gistbuild;

src/backend/access/hash/hash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ hashhandler(PG_FUNCTION_ARGS)
6767
amroutine->amstorage = false;
6868
amroutine->amclusterable = false;
6969
amroutine->ampredlocks = false;
70+
amroutine->amcanparallel = false;
7071
amroutine->amkeytype = INT4OID;
7172

7273
amroutine->ambuild = hashbuild;

src/backend/access/nbtree/nbtree.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ bthandler(PG_FUNCTION_ARGS)
140140
amroutine->amstorage = false;
141141
amroutine->amclusterable = true;
142142
amroutine->ampredlocks = true;
143+
amroutine->amcanparallel = true;
143144
amroutine->amkeytype = InvalidOid;
144145

145146
amroutine->ambuild = btbuild;

src/backend/access/spgist/spgutils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ spghandler(PG_FUNCTION_ARGS)
4949
amroutine->amstorage = false;
5050
amroutine->amclusterable = false;
5151
amroutine->ampredlocks = false;
52+
amroutine->amcanparallel = false;
5253
amroutine->amkeytype = InvalidOid;
5354

5455
amroutine->ambuild = spgbuild;

0 commit comments

Comments
 (0)