Skip to content

Commit

Permalink
[columnar] delete the scanContext whenever possible after creation (#226
Browse files Browse the repository at this point in the history
)
  • Loading branch information
JerrySievert authored Jan 17, 2024
1 parent 52eb55d commit 9d98073
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions columnar/src/backend/columnar/columnar_tableam.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ columnar_beginscan_extended(Relation relation, Snapshot snapshot,
return ((TableScanDesc) scan);
}


/*
* CreateColumnarScanMemoryContext creates a memory context to store
* ColumnarReadStare in it.
Expand Down Expand Up @@ -334,6 +333,8 @@ columnar_endscan(TableScanDesc sscan)
ColumnarResetCache();
}

MemoryContextDelete(scan->scanContext);

columnar_enable_page_cache = previousCacheEnabledState;
}

Expand Down Expand Up @@ -579,6 +580,8 @@ columnar_index_fetch_end(IndexFetchTableData *sscan)
{
ColumnarResetCache();
}

MemoryContextDelete(scan->scanContext);
}

static StripeMetadata *
Expand Down Expand Up @@ -1020,7 +1023,6 @@ columnar_tuple_complete_speculative(Relation relation, TupleTableSlot *slot,
columnar_enable_page_cache = previousCacheEnabledState;
}


static void
columnar_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,
CommandId cid, int options, BulkInsertState bistate)
Expand Down Expand Up @@ -1075,7 +1077,7 @@ columnar_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples,

tupleSlot->tts_tid = row_number_to_tid(writtenRowNumber);

MemoryContextReset(ColumnarWritePerTupleContext(writeState));
MemoryContextResetAndDeleteChildren(ColumnarWritePerTupleContext(writeState));
}

MemoryContextSwitchTo(oldContext);
Expand Down Expand Up @@ -1384,6 +1386,7 @@ columnar_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap,

ColumnarEndWrite(writeState);
ColumnarEndRead(readState);
MemoryContextDelete(scanContext);
}


Expand Down Expand Up @@ -1599,6 +1602,7 @@ TruncateAndCombineColumnarStripes(Relation rel, int elevel)

ColumnarEndWrite(writeState);
ColumnarEndRead(readState);
MemoryContextDelete(scanContext);

for (int i = 0; i < startingStripeListPosition; i++)
{
Expand Down

0 comments on commit 9d98073

Please sign in to comment.