Use stricter qual for pruning if both >/< and >=/<= are present.

Previously, if both =< and < (>= and < respectively) were specified,
we always used the latter restriction.  Instead use the stricter one.
support-6.1-faster-pruning
Andres Freund 2017-04-28 17:16:42 -07:00 committed by Jason Petersen
parent bb456d4002
commit 7a0f02f186
No known key found for this signature in database
GPG Key ID: 9F1D3510D110ABA9
1 changed files with 26 additions and 6 deletions

View File

@ -1158,9 +1158,19 @@ PruneWithBoundaries(DistTableCacheEntry *cacheEntry, ClauseWalkerContext *contex
} }
if (prune->greaterConsts) if (prune->greaterConsts)
{ {
lowerBound = prune->greaterConsts->constvalue; /*
lowerBoundInclusive = false; * Use the more restrictive one, if both greater and greaterEqual
hasLowerBound = true; * constraints are specified.
*/
if (!hasLowerBound ||
PerformValueCompare(compareFunctionCall,
prune->greaterConsts->constvalue,
lowerBound) >= 0)
{
lowerBound = prune->greaterConsts->constvalue;
lowerBoundInclusive = false;
hasLowerBound = true;
}
} }
if (prune->lessEqualConsts) if (prune->lessEqualConsts)
{ {
@ -1170,9 +1180,19 @@ PruneWithBoundaries(DistTableCacheEntry *cacheEntry, ClauseWalkerContext *contex
} }
if (prune->lessConsts) if (prune->lessConsts)
{ {
upperBound = prune->lessConsts->constvalue; /*
upperBoundInclusive = false; * Use the more restrictive one, if both less and lessEqual
hasUpperBound = true; * constraints are specified.
*/
if (!hasUpperBound ||
PerformValueCompare(compareFunctionCall,
prune->lessConsts->constvalue,
upperBound) <= 0)
{
upperBound = prune->lessConsts->constvalue;
upperBoundInclusive = false;
hasUpperBound = true;
}
} }
Assert(hasLowerBound || hasUpperBound); Assert(hasLowerBound || hasUpperBound);