Skip to content

Commit 0a6266d

Browse files
huansongreshke
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 58d08f8 commit 0a6266d

File tree

62 files changed

+328
-354
lines changed

Some content is hidden

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

62 files changed

+328
-354
lines changed

src/backend/access/aocs/aocs_compaction.c

Lines changed: 0 additions & 1 deletion
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

Lines changed: 8 additions & 14 deletions
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

@@ -936,8 +934,8 @@ aocs_insert_init(Relation rel, int segno)
936934
desc->compType = NameStr(nd);
937935

938936
GetAppendOnlyEntryAuxOids(rel,
939-
&desc->segrelid, &desc->blkdirrelid, NULL,
940-
&desc->visimaprelid, &desc->visimapidxid);
937+
&desc->segrelid, &desc->blkdirrelid,
938+
&desc->visimaprelid);
941939

942940
OpenAOCSDatumStreams(desc);
943941

@@ -1399,10 +1397,9 @@ aocs_fetch_init(Relation relation,
13991397

14001398
bool checksum;
14011399
Oid visimaprelid;
1402-
Oid visimapidxid;
14031400
GetAppendOnlyEntryAuxOids(relation,
1404-
&aocsFetchDesc->segrelid, NULL, NULL,
1405-
&visimaprelid, &visimapidxid);
1401+
&aocsFetchDesc->segrelid, NULL,
1402+
&visimaprelid);
14061403

14071404
GetAppendOnlyEntryAttributes(relation->rd_id,
14081405
NULL,
@@ -1495,7 +1492,6 @@ aocs_fetch_init(Relation relation,
14951492
pfree(opts);
14961493
AppendOnlyVisimap_Init(&aocsFetchDesc->visibilityMap,
14971494
visimaprelid,
1498-
visimapidxid,
14991495
AccessShareLock,
15001496
appendOnlyMetaDataSnapshot);
15011497

@@ -1766,20 +1762,18 @@ aocs_delete_init(Relation rel)
17661762
* Get the pg_appendonly information
17671763
*/
17681764
Oid visimaprelid;
1769-
Oid visimapidxid;
17701765
AOCSDeleteDesc aoDeleteDesc = palloc0(sizeof(AOCSDeleteDescData));
17711766

17721767
aoDeleteDesc->aod_rel = rel;
17731768

17741769
Snapshot snapshot = GetCatalogSnapshot(InvalidOid);
17751770

17761771
GetAppendOnlyEntryAuxOids(rel,
1777-
NULL, NULL, NULL,
1778-
&visimaprelid, &visimapidxid);
1772+
NULL, NULL,
1773+
&visimaprelid);
17791774

17801775
AppendOnlyVisimap_Init(&aoDeleteDesc->visibilityMap,
17811776
visimaprelid,
1782-
visimapidxid,
17831777
RowExclusiveLock,
17841778
snapshot);
17851779

src/backend/access/aocs/aocsam_handler.c

Lines changed: 4 additions & 5 deletions
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

Lines changed: 17 additions & 18 deletions
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/aosegfiles.c

Lines changed: 10 additions & 10 deletions
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

Lines changed: 2 additions & 2 deletions
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)