Skip to content

Commit 2f80123

Browse files
huansongavamingli
authored andcommitted
Remove visimapidxid and blkdiridxid fields from pg_appendonly
We can get indexes for blkdir and visimap from pg_index via `RelationGetIndexList`. Removing these 2 fields will reduce catalog size. Basically, we now deal with these two properties in a more similar way as the indexes of toast tables, where we always open the toast table first and then get its index via `RelationGetIndexList`. In fact, in majority of the places currently we already have those two aux tables opened. The only place we didn't is in ATExecSetTableSpace(), but it shouldn't slow down that function too much anyway. The other notable thing is that we need to modify how we get these indexes in pg_dump - we now have to check the pg_index.
1 parent c641c00 commit 2f80123

File tree

63 files changed

+331
-358
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+331
-358
lines changed

src/backend/access/aocs/aocs_compaction.c

-1
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ AOCSSegmentFileFullCompaction(Relation aorel,
259259

260260
AppendOnlyVisimap_Init(&visiMap,
261261
insertDesc->visimaprelid,
262-
insertDesc->visimapidxid,
263262
ShareLock,
264263
snapshot);
265264

src/backend/access/aocs/aocsam.c

+8-14
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,6 @@ aocs_beginscan_internal(Relation relation,
551551
AOCSScanDesc scan;
552552
AttrNumber natts;
553553
Oid visimaprelid;
554-
Oid visimapidxid;
555554

556555
scan = (AOCSScanDesc) palloc0(sizeof(AOCSScanDescData));
557556
scan->rs_base.rs_rd = relation;
@@ -599,13 +598,12 @@ aocs_beginscan_internal(Relation relation,
599598
NULL);
600599

601600
GetAppendOnlyEntryAuxOids(relation,
602-
NULL, NULL, NULL,
603-
&visimaprelid, &visimapidxid);
601+
NULL, NULL,
602+
&visimaprelid);
604603

605604
if (scan->total_seg != 0)
606605
AppendOnlyVisimap_Init(&scan->visibilityMap,
607606
visimaprelid,
608-
visimapidxid,
609607
AccessShareLock,
610608
appendOnlyMetaDataSnapshot);
611609

@@ -1083,8 +1081,8 @@ aocs_insert_init(Relation rel, int segno)
10831081
desc->compType = NameStr(nd);
10841082

10851083
GetAppendOnlyEntryAuxOids(rel,
1086-
&desc->segrelid, &desc->blkdirrelid, NULL,
1087-
&desc->visimaprelid, &desc->visimapidxid);
1084+
&desc->segrelid, &desc->blkdirrelid,
1085+
&desc->visimaprelid);
10881086

10891087
OpenAOCSDatumStreams(desc);
10901088

@@ -1545,10 +1543,9 @@ aocs_fetch_init(Relation relation,
15451543

15461544
bool checksum;
15471545
Oid visimaprelid;
1548-
Oid visimapidxid;
15491546
GetAppendOnlyEntryAuxOids(relation,
1550-
&aocsFetchDesc->segrelid, NULL, NULL,
1551-
&visimaprelid, &visimapidxid);
1547+
&aocsFetchDesc->segrelid, NULL,
1548+
&visimaprelid);
15521549

15531550
GetAppendOnlyEntryAttributes(relation->rd_id,
15541551
NULL,
@@ -1641,7 +1638,6 @@ aocs_fetch_init(Relation relation,
16411638
pfree(opts);
16421639
AppendOnlyVisimap_Init(&aocsFetchDesc->visibilityMap,
16431640
visimaprelid,
1644-
visimapidxid,
16451641
AccessShareLock,
16461642
appendOnlyMetaDataSnapshot);
16471643

@@ -1912,20 +1908,18 @@ aocs_delete_init(Relation rel)
19121908
* Get the pg_appendonly information
19131909
*/
19141910
Oid visimaprelid;
1915-
Oid visimapidxid;
19161911
AOCSDeleteDesc aoDeleteDesc = palloc0(sizeof(AOCSDeleteDescData));
19171912

19181913
aoDeleteDesc->aod_rel = rel;
19191914

19201915
Snapshot snapshot = GetCatalogSnapshot(InvalidOid);
19211916

19221917
GetAppendOnlyEntryAuxOids(rel,
1923-
NULL, NULL, NULL,
1924-
&visimaprelid, &visimapidxid);
1918+
NULL, NULL,
1919+
&visimaprelid);
19251920

19261921
AppendOnlyVisimap_Init(&aoDeleteDesc->visibilityMap,
19271922
visimaprelid,
1928-
visimapidxid,
19291923
RowExclusiveLock,
19301924
snapshot);
19311925

src/backend/access/aocs/aocsam_handler.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -1389,8 +1389,8 @@ aoco_relation_nontransactional_truncate(Relation rel)
13891389
/* Also truncate the aux tables */
13901390
GetAppendOnlyEntryAuxOids(rel,
13911391
&aoseg_relid,
1392-
&aoblkdir_relid, NULL,
1393-
&aovisimap_relid, NULL);
1392+
&aoblkdir_relid,
1393+
&aovisimap_relid);
13941394

13951395
heap_truncate_one_relid(aoseg_relid);
13961396
heap_truncate_one_relid(aoblkdir_relid);
@@ -1702,7 +1702,6 @@ aoco_index_build_range_scan(Relation heapRelation,
17021702
List *tlist = NIL;
17031703
List *qual = indexInfo->ii_Predicate;
17041704
Oid blkdirrelid;
1705-
Oid blkidxrelid;
17061705
int64 previous_blkno = -1;
17071706
Relation blkdir;
17081707

@@ -1748,7 +1747,7 @@ aoco_index_build_range_scan(Relation heapRelation,
17481747
* If block directory is empty, it must also be built along with the index.
17491748
*/
17501749
GetAppendOnlyEntryAuxOids(heapRelation, NULL,
1751-
&blkdirrelid, &blkidxrelid, NULL, NULL);
1750+
&blkdirrelid, NULL);
17521751

17531752
blkdir = relation_open(blkdirrelid, AccessShareLock);
17541753

@@ -2138,7 +2137,7 @@ aoco_relation_get_block_sequence(Relation rel,
21382137
{
21392138
Oid segrelid;
21402139

2141-
GetAppendOnlyEntryAuxOids(rel, &segrelid, NULL, NULL, NULL, NULL);
2140+
GetAppendOnlyEntryAuxOids(rel, &segrelid, NULL, NULL);
21422141
AOSegment_PopulateBlockSequence(sequence, segrelid, AOSegmentGet_segno(blkNum));
21432142
}
21442143

src/backend/access/aocs/aocssegfiles.c

+17-18
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,10 @@ GetAOCSFileSegInfo(Relation prel,
219219
Datum *d;
220220
bool *null;
221221
bool isNull;
222+
Oid segrelid;
222223

223-
Oid segrelid;
224-
GetAppendOnlyEntryAuxOids(prel,
225-
&segrelid, NULL, NULL,
226-
NULL, NULL);
224+
GetAppendOnlyEntryAuxOids(prel,
225+
&segrelid, NULL, NULL);
227226

228227
segrel = heap_open(segrelid, AccessShareLock);
229228
tupdesc = RelationGetDescr(segrel);
@@ -329,7 +328,7 @@ GetAllAOCSFileSegInfo(Relation prel,
329328
Assert(RelationStorageIsAoCols(prel));
330329

331330
GetAppendOnlyEntryAuxOids(prel,
332-
&segrelid, NULL, NULL,
331+
&segrelid,
333332
NULL, NULL);
334333

335334
if (segrelid == InvalidOid)
@@ -587,7 +586,7 @@ MarkAOCSFileSegInfoAwaitingDrop(Relation prel, int segno)
587586

588587
appendOnlyMetaDataSnapshot = RegisterSnapshot(GetCatalogSnapshot(InvalidOid));
589588
GetAppendOnlyEntryAuxOids(prel,
590-
&segrelid, NULL, NULL,
589+
&segrelid,
591590
NULL, NULL);
592591
UnregisterSnapshot(appendOnlyMetaDataSnapshot);
593592

@@ -675,7 +674,7 @@ ClearAOCSFileSegInfo(Relation prel, int segno)
675674

676675
appendOnlyMetaDataSnapshot = RegisterSnapshot(GetCatalogSnapshot(InvalidOid));
677676
GetAppendOnlyEntryAuxOids(prel,
678-
&segrelid, NULL, NULL,
677+
&segrelid,
679678
NULL, NULL);
680679
UnregisterSnapshot(appendOnlyMetaDataSnapshot);
681680

@@ -957,7 +956,7 @@ AOCSFileSegInfoAddVpe(Relation prel, int32 segno,
957956

958957
Oid segrelid;
959958
GetAppendOnlyEntryAuxOids(prel,
960-
&segrelid, NULL, NULL,
959+
&segrelid,
961960
NULL, NULL);
962961
segrel = heap_open(segrelid, RowExclusiveLock);
963962
tupdesc = RelationGetDescr(segrel);
@@ -1071,7 +1070,7 @@ AOCSFileSegInfoAddCount(Relation prel, int32 segno,
10711070

10721071
Oid segrelid;
10731072
GetAppendOnlyEntryAuxOids(prel,
1074-
&segrelid, NULL, NULL,
1073+
&segrelid,
10751074
NULL, NULL);
10761075

10771076
segrel = heap_open(segrelid, RowExclusiveLock);
@@ -1201,6 +1200,7 @@ gp_aocsseg_internal(PG_FUNCTION_ARGS, Oid aocsRelOid)
12011200
Relation aocsRel;
12021201
Relation pg_aocsseg_rel;
12031202
Snapshot appendOnlyMetaDataSnapshot = RegisterSnapshot(GetLatestSnapshot());
1203+
Oid segrelid;
12041204

12051205
/* create a function context for cross-call persistence */
12061206
funcctx = SRF_FIRSTCALL_INIT();
@@ -1254,10 +1254,9 @@ gp_aocsseg_internal(PG_FUNCTION_ARGS, Oid aocsRelOid)
12541254
/* Remember the number of columns. */
12551255
context->relnatts = aocsRel->rd_rel->relnatts;
12561256

1257-
Oid segrelid;
1258-
GetAppendOnlyEntryAuxOids(aocsRel,
1259-
&segrelid, NULL, NULL,
1260-
NULL, NULL);
1257+
GetAppendOnlyEntryAuxOids(aocsRel,
1258+
&segrelid,
1259+
NULL, NULL);
12611260
pg_aocsseg_rel = heap_open(segrelid, AccessShareLock);
12621261

12631262
context->aocsSegfileArray = GetAllAOCSFileSegInfo_pg_aocsseg_rel(
@@ -1419,6 +1418,7 @@ gp_aocsseg_history(PG_FUNCTION_ARGS)
14191418
MemoryContext oldcontext;
14201419
Relation aocsRel;
14211420
Relation pg_aocsseg_rel;
1421+
Oid segrelid;
14221422

14231423
/* create a function context for cross-call persistence */
14241424
funcctx = SRF_FIRSTCALL_INIT();
@@ -1474,10 +1474,9 @@ gp_aocsseg_history(PG_FUNCTION_ARGS)
14741474
/* Remember the number of columns. */
14751475
context->relnatts = aocsRel->rd_rel->relnatts;
14761476

1477-
Oid segrelid;
1478-
GetAppendOnlyEntryAuxOids(aocsRel,
1479-
&segrelid, NULL, NULL,
1480-
NULL, NULL);
1477+
GetAppendOnlyEntryAuxOids(aocsRel,
1478+
&segrelid,
1479+
NULL, NULL);
14811480

14821481
pg_aocsseg_rel = heap_open(segrelid, AccessShareLock);
14831482

@@ -1609,7 +1608,7 @@ aocol_compression_ratio_internal(Relation parentrel)
16091608
Assert(Gp_role == GP_ROLE_DISPATCH || Gp_role == GP_ROLE_UTILITY);
16101609

16111610
GetAppendOnlyEntryAuxOids(parentrel,
1612-
&segrelid, NULL, NULL, NULL, NULL);
1611+
&segrelid, NULL, NULL);
16131612
Assert(OidIsValid(segrelid));
16141613

16151614
/*

src/backend/access/appendonly/aomd.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ ao_rel_get_physical_size(Relation aorel)
643643
Assert(RelationStorageIsAO(aorel));
644644

645645
GetAppendOnlyEntryAuxOids(aorel,
646-
&segrelid, NULL, NULL, NULL, NULL);
646+
&segrelid, NULL, NULL);
647647

648648
pg_aoseg_rel = heap_open(segrelid, AccessShareLock);
649649
pg_aoseg_dsc = RelationGetDescr(pg_aoseg_rel);

src/backend/access/appendonly/aosegfiles.c

+10-10
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ InsertInitialSegnoEntry(Relation parentrel, int segno)
109109
/* New segments are always created in the latest format */
110110
formatVersion = AOSegfileFormatVersion_GetLatest();
111111

112-
GetAppendOnlyEntryAuxOids(parentrel, &segrelid, NULL, NULL, NULL, NULL);
112+
GetAppendOnlyEntryAuxOids(parentrel, &segrelid, NULL, NULL);
113113

114114
pg_aoseg_rel = heap_open(segrelid, RowExclusiveLock);
115115

@@ -194,7 +194,7 @@ GetFileSegInfo(Relation parentrel, Snapshot appendOnlyMetaDataSnapshot, int segn
194194
FileSegInfo *fsinfo;
195195
Oid segrelid;
196196

197-
GetAppendOnlyEntryAuxOids(parentrel, &segrelid, NULL, NULL, NULL, NULL);
197+
GetAppendOnlyEntryAuxOids(parentrel, &segrelid, NULL, NULL);
198198

199199
/*
200200
* Check the pg_aoseg relation to be certain the ao table segment file is
@@ -360,7 +360,7 @@ GetAllFileSegInfo(Relation parentrel,
360360
FileSegInfo **result;
361361
Oid segrelid;
362362

363-
GetAppendOnlyEntryAuxOids(parentrel, &segrelid, NULL, NULL, NULL, NULL);
363+
GetAppendOnlyEntryAuxOids(parentrel, &segrelid, NULL, NULL);
364364

365365
if (segrelid == InvalidOid)
366366
elog(ERROR, "could not find pg_aoseg aux table for AO table \"%s\"",
@@ -622,7 +622,7 @@ ClearFileSegInfo(Relation parentrel, int segno)
622622
bool isNull;
623623
Oid segrelid;
624624

625-
GetAppendOnlyEntryAuxOids(parentrel, &segrelid, NULL, NULL, NULL, NULL);
625+
GetAppendOnlyEntryAuxOids(parentrel, &segrelid, NULL, NULL);
626626

627627
elogif(Debug_appendonly_print_compaction, LOG,
628628
"Clear seg file info: segno %d table '%s'",
@@ -759,7 +759,7 @@ UpdateFileSegInfo_internal(Relation parentrel,
759759
Oid segrelid;
760760

761761
Assert(RelationStorageIsAoRows(parentrel));
762-
GetAppendOnlyEntryAuxOids(parentrel, &segrelid, NULL, NULL, NULL, NULL);
762+
GetAppendOnlyEntryAuxOids(parentrel, &segrelid, NULL, NULL);
763763

764764
Assert(newState >= AOSEG_STATE_USECURRENT && newState <= AOSEG_STATE_AWAITING_DROP);
765765

@@ -963,7 +963,7 @@ GetSegFilesTotals(Relation parentrel, Snapshot appendOnlyMetaDataSnapshot)
963963

964964
result = (FileSegTotals *) palloc0(sizeof(FileSegTotals));
965965

966-
GetAppendOnlyEntryAuxOids(parentrel, &segrelid, NULL, NULL, NULL, NULL);
966+
GetAppendOnlyEntryAuxOids(parentrel, &segrelid, NULL, NULL);
967967

968968
if (segrelid == InvalidOid)
969969
elog(ERROR, "could not find pg_aoseg aux table for AO table \"%s\"",
@@ -1082,7 +1082,7 @@ gp_aoseg_history(PG_FUNCTION_ARGS)
10821082
errmsg("Relation '%s' does not have appendoptimized row-oriented storage",
10831083
RelationGetRelationName(aocsRel))));
10841084

1085-
GetAppendOnlyEntryAuxOids(aocsRel, &segrelid, NULL, NULL, NULL, NULL);
1085+
GetAppendOnlyEntryAuxOids(aocsRel, &segrelid, NULL, NULL);
10861086

10871087
pg_aoseg_rel = table_open(segrelid, AccessShareLock);
10881088

@@ -1234,7 +1234,7 @@ gp_aoseg(PG_FUNCTION_ARGS)
12341234
errmsg("Relation '%s' does not have appendoptimized row-oriented storage",
12351235
RelationGetRelationName(aocsRel))));
12361236

1237-
GetAppendOnlyEntryAuxOids(aocsRel, &segrelid, NULL, NULL, NULL, NULL);
1237+
GetAppendOnlyEntryAuxOids(aocsRel, &segrelid, NULL, NULL);
12381238

12391239
pg_aoseg_rel = table_open(segrelid, AccessShareLock);
12401240

@@ -1391,7 +1391,7 @@ get_ao_distribution(PG_FUNCTION_ARGS)
13911391
RelationGetRelationName(parentrel))));
13921392

13931393
GetAppendOnlyEntryAuxOids(parentrel,
1394-
&segrelid, NULL, NULL, NULL, NULL);
1394+
&segrelid, NULL, NULL);
13951395
Assert(OidIsValid(segrelid));
13961396

13971397
/*
@@ -1575,7 +1575,7 @@ aorow_compression_ratio_internal(Relation parentrel)
15751575

15761576
GetAppendOnlyEntryAuxOids(parentrel,
15771577
&segrelid,
1578-
NULL, NULL, NULL, NULL);
1578+
NULL, NULL);
15791579
Assert(OidIsValid(segrelid));
15801580

15811581
/*

src/backend/access/appendonly/appendonly_blkdir_udf.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ gp_aoblkdir(PG_FUNCTION_ARGS)
9898
errmsg("function not supported on non append-optimized relation")));
9999
sst = GetLatestSnapshot();
100100
GetAppendOnlyEntryAuxOids(context->aorel,
101-
NULL, &blkdirrelid, NULL,
102-
NULL, NULL);
101+
NULL, &blkdirrelid,
102+
NULL);
103103
sst = gp_select_invisible ? SnapshotAny : GetLatestSnapshot();
104104
if (blkdirrelid == InvalidOid)
105105
ereport(ERROR,

0 commit comments

Comments
 (0)