File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -922,6 +922,7 @@ InitPlan(QueryDesc *queryDesc, int eflags)
922
922
if (plan -> targetlist != NULL ) {
923
923
piggyback = (Piggyback * ) (malloc (sizeof (Piggyback )));
924
924
piggyback -> root = NULL ;
925
+ piggyback -> fdsPruned = false;
925
926
piggyback -> numberOfAttributes = plan -> targetlist -> length ;
926
927
piggyback -> slotValues = (char * * )malloc (piggyback -> numberOfAttributes * sizeof (char * ));
927
928
Original file line number Diff line number Diff line change @@ -704,10 +704,42 @@ ExecProcNode(PlanState *node) {
704
704
return result ;
705
705
}
706
706
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
+
707
733
/*
708
734
* Stores FD combinations in HashMap, if already existing and conflicting: mark FD as invalid
709
735
*/
710
736
void fillFDCandidateMaps () {
737
+
738
+ if (!piggyback -> fdsPruned ){
739
+ prune ();
740
+ piggyback -> fdsPruned = true;
741
+ }
742
+
711
743
int i ;
712
744
int blockSize = piggyback -> numberOfAttributes - 1 ;
713
745
for (i = 0 ; i < piggyback -> numberOfAttributes ; i ++ ){
Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ extern void printIt();
94
94
typedef struct _piggyback {
95
95
be_PGStatistics * resultStatistics ;
96
96
Plan * root ;
97
+ bool fdsPruned ;
97
98
hashset_t * distinctValues ;
98
99
hashmap * * twoColumnsCombinations ;
99
100
// temporary save values for each column of a slot
You can’t perform that action at this time.
0 commit comments