10000 added some pruning for fds · mpws2013n1/postgres@44526a0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 44526a0

Browse files
committed
added some pruning for fds
1 parent 7a3db86 commit 44526a0

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

src/backend/executor/execMain.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ InitPlan(QueryDesc *queryDesc, int eflags)
922922
if (plan->targetlist != NULL) {
923923
piggyback = (Piggyback*) (malloc(sizeof(Piggyback)));
924924
piggyback->root = NULL;
925+
piggyback->fdsPruned = false;
925926
piggyback->numberOfAttributes = plan->targetlist->length;
926927
piggyback->slotValues = (char**)malloc(piggyback->numberOfAttributes * sizeof(char*));
927928

src/backend/executor/execProcnode.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,10 +704,42 @@ ExecProcNode(PlanState *node) {
704704
return result;
705705
}
706706

707+
void prune(){
708+
int i;
709+
int blockSize = piggyback->numberOfAttributes - 1;
710+
for (i = 0; i < piggyback->numberOfAttributes; i++) {
711+
int j;
712+
for (j = 0; j < piggyback->numberOfAttributes; j++) {
713+
if (i == j) {
714+
continue;
715+
}
716+
int indexBlock = i * blockSize;
717+
int indexSummand = j > i ? j - 1 : j;
718+
int index = indexBlock + indexSummand;
719+
720+
if (piggyback->resultStatistics->columnStatistics[i].n_distinct != 0
721+
&& piggyback->resultStatistics->columnStatistics[j].n_distinct != 0) {
722+
if (piggyback->resultStatistics->columnStatistics[i].n_distinct
723+
< piggyback->resultStatistics->columnStatistics[j].n_distinct
724+
&& piggyback->resultStatistics->columnStatistics[j].n_distinctIsFinal) {
725+
hashmapDelete(piggyback->twoColumnsCombinations[index]);
726+
piggyback->twoColumnsCombinations[index] = NULL;
727+
}
728+
}
729+
}
730+
}
731+
}
732+
707733
/*
708734
* Stores FD combinations in HashMap, if already existing and conflicting: mark FD as invalid
709735
*/
710736
void fillFDCandidateMaps() {
737+
738+
if(!piggyback->fdsPruned){
739+
prune();
740+
piggyback->fdsPruned = true;
741+
}
742+
711743
int i;
712744
int blockSize = piggyback->numberOfAttributes-1;
713745
for(i=0; i< piggyback->numberOfAttributes; i++){

src/include/piggyback/piggyback.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ extern void printIt();
9494
typedef struct _piggyback {
9595
be_PGStatistics *resultStatistics;
9696
Plan *root;
97+
bool fdsPruned;
9798
hashset_t *distinctValues;
9899
hashmap **twoColumnsCombinations;
99100
// temporary save values for each column of a slot

0 commit comments

Comments
 (0)
0