RANGE partition pruning can still exclude the default partition

Started by Ewan Young4 months ago7 messageshackers
Jump to latest
#1Ewan Young
kdbase.hack@gmail.com

Hi,

Issue still happens on master as of 9b917a93116, i.e. with 709dfd27f14
already applied. It is a different instance of the same defect, in another
branch of the same function, and it silently returns wrong results.

CREATE TABLE t (a int, b int) PARTITION BY RANGE (a, b);
CREATE TABLE t1 PARTITION OF t FOR VALUES FROM (13, 0) TO (19, MAXVALUE);
CREATE TABLE td PARTITION OF t DEFAULT;
INSERT INTO t VALUES (32, 5);

SELECT count(*) FROM t WHERE a = 32; -- 1, correct
SELECT count(*) FROM t WHERE a = 32 AND b >= -7; -- 0, should be 1

Adding a qual that is true for every matching row makes the row disappear;
the plan is a One-Time Filter: false. It takes a multi-column range key, a
bound unbounded in a trailing key but finite in the first key, and a query
constraining all key columns - with nvalues < partnatts,
get_matching_range_bounds() sets scan_default up front, which masks it.
DELETE and UPDATE silently skip rows as well, run-time pruning is affected,
and FROM (13, MINVALUE) is the mirror image. A layout that hits this in
the wild is RANGE (tenant_id, ts) with FROM (N, MINVALUE) TO (N, MAXVALUE)
per tenant plus a default partition.

At the end of get_matching_range_bounds() two adjustments drop the extreme
bound offset when no partition covers the key space beyond it:

int lastkey = nvalues - 1;

if (boundinfo->kind[maxoff - 1][lastkey] == PARTITION_RANGE_DATUM_MAXVALUE)
maxoff--;

Only a bound unbounded in its *first* key has no key space beyond it.
TO (19, MAXVALUE) merely means "unbounded within a = 19"; above it is real
key space owned by the default partition. Dropping the offset also drops
the last signal that the default has to be scanned: since 489247b0e615
get_matching_partitions() derives that from a returned offset whose
partindices[] entry is -1, and scan_default is not set on this path.

709dfd27f14 removed the equivalent adjustment from the nvalues == 0 path
for exactly this reason. These two blocks predate it - 9fdb675fc5d2 for
the surrounding code, 489247b0e615 for the kind[] tests - and are
byte-identical from REL_13_STABLE through master. I found no prior report
of the multi-column case; the 709dfd27f14 thread covers only the
IS NOT NULL / combine-step interaction, and the 2019 and 2018 default-
pruning threads go the other way.

0001 tests the first key of the bound instead of the last key of the lookup
value; the code change is two lines. I did not delete the blocks the way
709dfd27f14 did, because when the first key really is unbounded there is
nothing beyond it and removing them would scan the default partition for no
reason. Tests cover a trailing MAXVALUE, the MINVALUE mirror, a genuinely
unbounded first key, and the no-default case; the last two are unchanged by
the patch, on purpose.

0001 alone gives up one pruning opportunity: "WHERE a = 19 AND b >= 5" now
also scans the default partition. That pruning was unsound where it
happened - "WHERE a >= 19 AND b >= 5" makes the identical call (strategy

=, values (19, 5)), and there the rows above the bound do qualify; master

answers it with 2 rows where 3 is correct. The function cannot tell the
two apart.

0002 recovers it where the knowledge exists. In the equality-prefix path
the code already skips the offset below the smallest matching bound when
that bound is (prefix, MINVALUE); the mirror was missing, so a greatest
matching bound of (prefix, MAXVALUE) still pulled in the offset above it.
With 0002, "WHERE a = 19 AND b >= 5" scans t1 only, while "a >= 19 AND
b >= 5" and plain "a = 19" still scan the default partition, the latter
because a NULL in a later key is routed there. 0002 is a pruning
improvement rather than a correctness fix, hence the split.

make check passes 245/245 with 0001 alone and with both applied, with no
changes to existing expected output; src/test/recovery and
src/test/subscription pass as well.

--
Regards,
Ewan Young

Attachments:

t253332_1
v1-0001-Don-t-prune-the-default-partition-for-bounds-unbound.patchapplication/octet-stream; name=v1-0001-Don-t-prune-the-default-partition-for-bounds-unbound.patchDownload+172-17
v1-0002-Prune-the-default-partition-for-an-equality-prefix-e.patchapplication/octet-stream; name=v1-0002-Prune-the-default-partition-for-an-equality-prefix-e.patchDownload+34-3
#2Tender Wang
tndrwang@gmail.com
In reply to: Ewan Young (#1)
Re: RANGE partition pruning can still exclude the default partition

Hi Ewan,

Ewan Young <kdbase.hack@gmail.com> 于2026年8月6日周四 18:47写道:

Hi,

Issue still happens on master as of 9b917a93116, i.e. with 709dfd27f14
already applied. It is a different instance of the same defect, in another
branch of the same function, and it silently returns wrong results.

CREATE TABLE t (a int, b int) PARTITION BY RANGE (a, b);
CREATE TABLE t1 PARTITION OF t FOR VALUES FROM (13, 0) TO (19, MAXVALUE);
CREATE TABLE td PARTITION OF t DEFAULT;
INSERT INTO t VALUES (32, 5);

SELECT count(*) FROM t WHERE a = 32; -- 1, correct
SELECT count(*) FROM t WHERE a = 32 AND b >= -7; -- 0, should be 1

Nice catch.

Adding a qual that is true for every matching row makes the row disappear;
the plan is a One-Time Filter: false. It takes a multi-column range key, a
bound unbounded in a trailing key but finite in the first key, and a query
constraining all key columns - with nvalues < partnatts,
get_matching_range_bounds() sets scan_default up front, which masks it.
DELETE and UPDATE silently skip rows as well, run-time pruning is affected,
and FROM (13, MINVALUE) is the mirror image. A layout that hits this in
the wild is RANGE (tenant_id, ts) with FROM (N, MINVALUE) TO (N, MAXVALUE)
per tenant plus a default partition.

At the end of get_matching_range_bounds() two adjustments drop the extreme
bound offset when no partition covers the key space beyond it:

int lastkey = nvalues - 1;

if (boundinfo->kind[maxoff - 1][lastkey] == PARTITION_RANGE_DATUM_MAXVALUE)
maxoff--;

Only a bound unbounded in its *first* key has no key space beyond it.
TO (19, MAXVALUE) merely means "unbounded within a = 19"; above it is real
key space owned by the default partition. Dropping the offset also drops
the last signal that the default has to be scanned: since 489247b0e615
get_matching_partitions() derives that from a returned offset whose
partindices[] entry is -1, and scan_default is not set on this path.

Yes, I came to the same conclusion.

0001 tests the first key of the bound instead of the last key of the lookup
value; the code change is two lines. I did not delete the blocks the way
709dfd27f14 did, because when the first key really is unbounded there is
nothing beyond it and removing them would scan the default partition for no
reason. Tests cover a trailing MAXVALUE, the MINVALUE mirror, a genuinely
unbounded first key, and the no-default case; the last two are unchanged by
the patch, on purpose.

The fix WFM. I tweaked the comments a little, as in the attached v2-0001 patch.
Others look good to me.

--
Thanks,
Tender Wang

Attachments:

t253332_2
v2-0001-Don-t-prune-the-default-partition-for-bounds-unbo.patchapplication/octet-stream; name=v2-0001-Don-t-prune-the-default-partition-for-bounds-unbo.patchDownload+173-18
#3Radim Marek
radim@boringsql.com
In reply to: Tender Wang (#2)
Re: RANGE partition pruning can still exclude the default partition

Hey,

I'm not sure the patch is a full fix, even with 6e5d5680b555 applied.

CREATE TABLE t (a int, b int) PARTITION BY RANGE (a, b);
CREATE TABLE t1 PARTITION OF t FOR VALUES FROM (13, 0) TO (19,
MAXVALUE);
CREATE TABLE td PARTITION OF t DEFAULT;
INSERT INTO t VALUES (32, 5);

SELECT count(*) FROM t WHERE a = 32; -- 1
SELECT count(*) FROM t WHERE a = 32 AND b >= -7; -- 0, expected 1

SET enable_partition_pruning = off;
SELECT count(*) FROM t WHERE a = 32 AND b >= -7; -- 1

The two cases added by the commit (mc2ap, mc2bp) behave as described, so
this looks like a case it doesn't cover rather than a problem with it.

I only tested master, so I do not know how far back this might go. Found
while testing my planner-regression harness against recent commits.

Happy to test a patch against a broader set of partitioned queries if that
would help.

Regards,

Radim

On Mon, 10 Aug 2026 at 07:34, Tender Wang <tndrwang@gmail.com> wrote:

Show quoted text

Hi Ewan,

Ewan Young <kdbase.hack@gmail.com> 于2026年8月6日周四 18:47写道:

Hi,

Issue still happens on master as of 9b917a93116, i.e. with 709dfd27f14
already applied. It is a different instance of the same defect, in

another

branch of the same function, and it silently returns wrong results.

CREATE TABLE t (a int, b int) PARTITION BY RANGE (a, b);
CREATE TABLE t1 PARTITION OF t FOR VALUES FROM (13, 0) TO (19,

MAXVALUE);

CREATE TABLE td PARTITION OF t DEFAULT;
INSERT INTO t VALUES (32, 5);

SELECT count(*) FROM t WHERE a = 32; -- 1, correct
SELECT count(*) FROM t WHERE a = 32 AND b >= -7; -- 0, should be 1

Nice catch.

Adding a qual that is true for every matching row makes the row

disappear;

the plan is a One-Time Filter: false. It takes a multi-column range

key, a

bound unbounded in a trailing key but finite in the first key, and a

query

constraining all key columns - with nvalues < partnatts,
get_matching_range_bounds() sets scan_default up front, which masks it.
DELETE and UPDATE silently skip rows as well, run-time pruning is

affected,

and FROM (13, MINVALUE) is the mirror image. A layout that hits this in
the wild is RANGE (tenant_id, ts) with FROM (N, MINVALUE) TO (N,

MAXVALUE)

per tenant plus a default partition.

At the end of get_matching_range_bounds() two adjustments drop the

extreme

bound offset when no partition covers the key space beyond it:

int lastkey = nvalues - 1;

if (boundinfo->kind[maxoff - 1][lastkey] ==

PARTITION_RANGE_DATUM_MAXVALUE)

maxoff--;

Only a bound unbounded in its *first* key has no key space beyond it.
TO (19, MAXVALUE) merely means "unbounded within a = 19"; above it is

real

key space owned by the default partition. Dropping the offset also drops
the last signal that the default has to be scanned: since 489247b0e615
get_matching_partitions() derives that from a returned offset whose
partindices[] entry is -1, and scan_default is not set on this path.

Yes, I came to the same conclusion.

0001 tests the first key of the bound instead of the last key of the

lookup

value; the code change is two lines. I did not delete the blocks the way
709dfd27f14 did, because when the first key really is unbounded there is
nothing beyond it and removing them would scan the default partition for

no

reason. Tests cover a trailing MAXVALUE, the MINVALUE mirror, a

genuinely

unbounded first key, and the no-default case; the last two are unchanged

by

the patch, on purpose.

The fix WFM. I tweaked the comments a little, as in the attached v2-0001
patch.
Others look good to me.

--
Thanks,
Tender Wang

#4Ewan Young
kdbase.hack@gmail.com
In reply to: Radim Marek (#3)
Re: RANGE partition pruning can still exclude the default partition

Hi Radim,

Thanks for testing this -- that's exactly the case this thread is
about, and it's good to have independent confirmation from your
harness.

Just to untangle which fix is which: 6e5d5680b555 (David Rowley,
"Fix incorrect multi-column RANGE partition pruning") is a separate
bug in the loop bounds of get_matching_range_bounds(). It doesn't
touch the MINVALUE/MAXVALUE trailing-key blocks at the end of that
function, which is where your case comes from -- so your query is
still wrong on master even with it applied, as you found. The
mc2ap/mc2bp cases are Rowley's, and they're orthogonal to this one.

The fix for your exact query is the patch already on this thread (the
two-line change to test the *first* key of the bound instead of the
last key of the lookup value, plus Tender's comment tweaks in v2-0001).
I re-verified on current master (a9eebaf3735, i.e. with 6e5d5680b555
already in): your query returns 0 unpatched and 1 with the patch, and
Rowley's mc2ap cases still prune correctly. The patch's code hunk
applies cleanly over 6e5d5680b555; only the regression-test hunks
conflict because both add to partition_prune.sql, so I'll post a
rebased v3 that resolves that.

I'd gladly take you up on the offer to run a broader set of partitioned
queries against the rebased patch.

On Tue, Sep 1, 2026 at 8:10 PM Radim Marek <radim@boringsql.com> wrote:

Hey,

I'm not sure the patch is a full fix, even with 6e5d5680b555 applied.

CREATE TABLE t (a int, b int) PARTITION BY RANGE (a, b);
CREATE TABLE t1 PARTITION OF t FOR VALUES FROM (13, 0) TO (19, MAXVALUE);
CREATE TABLE td PARTITION OF t DEFAULT;
INSERT INTO t VALUES (32, 5);

SELECT count(*) FROM t WHERE a = 32; -- 1
SELECT count(*) FROM t WHERE a = 32 AND b >= -7; -- 0, expected 1

SET enable_partition_pruning = off;
SELECT count(*) FROM t WHERE a = 32 AND b >= -7; -- 1

The two cases added by the commit (mc2ap, mc2bp) behave as described, so this looks like a case it doesn't cover rather than a problem with it.

I only tested master, so I do not know how far back this might go. Found while testing my planner-regression harness against recent commits.

Happy to test a patch against a broader set of partitioned queries if that would help.

Regards,

Radim

On Mon, 10 Aug 2026 at 07:34, Tender Wang <tndrwang@gmail.com> wrote:

Hi Ewan,

Ewan Young <kdbase.hack@gmail.com> 于2026年8月6日周四 18:47写道:

Hi,

Issue still happens on master as of 9b917a93116, i.e. with 709dfd27f14
already applied. It is a different instance of the same defect, in another
branch of the same function, and it silently returns wrong results.

CREATE TABLE t (a int, b int) PARTITION BY RANGE (a, b);
CREATE TABLE t1 PARTITION OF t FOR VALUES FROM (13, 0) TO (19, MAXVALUE);
CREATE TABLE td PARTITION OF t DEFAULT;
INSERT INTO t VALUES (32, 5);

SELECT count(*) FROM t WHERE a = 32; -- 1, correct
SELECT count(*) FROM t WHERE a = 32 AND b >= -7; -- 0, should be 1

Nice catch.

Adding a qual that is true for every matching row makes the row disappear;
the plan is a One-Time Filter: false. It takes a multi-column range key, a
bound unbounded in a trailing key but finite in the first key, and a query
constraining all key columns - with nvalues < partnatts,
get_matching_range_bounds() sets scan_default up front, which masks it.
DELETE and UPDATE silently skip rows as well, run-time pruning is affected,
and FROM (13, MINVALUE) is the mirror image. A layout that hits this in
the wild is RANGE (tenant_id, ts) with FROM (N, MINVALUE) TO (N, MAXVALUE)
per tenant plus a default partition.

At the end of get_matching_range_bounds() two adjustments drop the extreme
bound offset when no partition covers the key space beyond it:

int lastkey = nvalues - 1;

if (boundinfo->kind[maxoff - 1][lastkey] == PARTITION_RANGE_DATUM_MAXVALUE)
maxoff--;

Only a bound unbounded in its *first* key has no key space beyond it.
TO (19, MAXVALUE) merely means "unbounded within a = 19"; above it is real
key space owned by the default partition. Dropping the offset also drops
the last signal that the default has to be scanned: since 489247b0e615
get_matching_partitions() derives that from a returned offset whose
partindices[] entry is -1, and scan_default is not set on this path.

Yes, I came to the same conclusion.

0001 tests the first key of the bound instead of the last key of the lookup
value; the code change is two lines. I did not delete the blocks the way
709dfd27f14 did, because when the first key really is unbounded there is
nothing beyond it and removing them would scan the default partition for no
reason. Tests cover a trailing MAXVALUE, the MINVALUE mirror, a genuinely
unbounded first key, and the no-default case; the last two are unchanged by
the patch, on purpose.

The fix WFM. I tweaked the comments a little, as in the attached v2-0001 patch.
Others look good to me.

--
Thanks,
Tender Wang

--
Regards,
Ewan Young

#5David Rowley
dgrowleyml@gmail.com
In reply to: Ewan Young (#1)
Re: RANGE partition pruning can still exclude the default partition

On Thu, 6 Aug 2026 at 22:47, Ewan Young <kdbase.hack@gmail.com> wrote:

0001 tests the first key of the bound instead of the last key of the lookup
value; the code change is two lines. I did not delete the blocks the way
709dfd27f14 did, because when the first key really is unbounded there is
nothing beyond it and removing them would scan the default partition for no
reason. Tests cover a trailing MAXVALUE, the MINVALUE mirror, a genuinely
unbounded first key, and the no-default case; the last two are unchanged by
the patch, on purpose.

0001 alone gives up one pruning opportunity: "WHERE a = 19 AND b >= 5" now
also scans the default partition. That pruning was unsound where it
happened - "WHERE a >= 19 AND b >= 5" makes the identical call (strategy

=, values (19, 5)), and there the rows above the bound do qualify; master

answers it with 2 rows where 3 is correct. The function cannot tell the
two apart.

0002 recovers it where the knowledge exists. In the equality-prefix path
the code already skips the offset below the smallest matching bound when
that bound is (prefix, MINVALUE); the mirror was missing, so a greatest
matching bound of (prefix, MAXVALUE) still pulled in the offset above it.
With 0002, "WHERE a = 19 AND b >= 5" scans t1 only, while "a >= 19 AND
b >= 5" and plain "a = 19" still scan the default partition, the latter
because a NULL in a later key is routed there. 0002 is a pruning
improvement rather than a correctness fix, hence the split.

I spent some time looking at these patches and I believe both the
changes together make sense. I feel the commentary around how all this
works is a bit lacking in general, however.

The reason to switch to only checking for MINVALUE / MAXVALUE on the
first partition key is because you've made it so the
BTEqualStrategyNumber code handles doing this for subsequent keys, and
since the step generation always generates steps with leading subsets
of the given values, the code you added to BTEqualStrategyNumber will
trim off the default when the final partition found by the
BTEqualStrategyNumber code for the leading prefix has a MAXVALUE
clause. For example, if you have a query doing "WHERE a = 19 AND b >=
5", the pruning code will generate 2 pruning steps, one for "a = 19"
and the 2nd with the full "a = 19 AND b >= 5". If there had been 3
clauses, then steps would be generated for each intermediate prefix of
the quals matching each partition key (i.e 3 pruning steps). When we
get the pruning results for the "a = 19" step, that hits the
BTEqualStrategyNumber code and because we don't have quals there for
all partition key columns, we must find all partitions that match "a =
19". There's a while loop doing that in the BTEqualStrategyNumber
case.

Because we generate steps for each combination of leading prefix of
clauses matching the partition key, the leading "a = 19" step going
through the BTEqualStrategyNumber code will detect if the final
partition we land on that matches "a = 19" has a MAXVALUE, and not
include the DEFAULT. Since the result of this step and the step
containing the quals for both keys are intersected, you only need to
prune the default partition in one of the steps for it not to appear
in the intersected result of all pruning steps.

I did modify the patch slightly so that the MINVALUE / MAXVALUE code
for the 0th partition key only executes when nvalues == 1. In the
example above, this means it only executes in the "a = 19" step and
not the "a = 19 and b >= 5" step. This doesn't make any difference to
the final result, but I think it makes more sense to do this as it
means we only apply that optimisation once rather than doing it
several times redundantly. I also tried to explain what's going on in
a paragraph of comments.

I've attached an AI-written and hand-modified fuzzing tool that I used
to check your patch doesn't prune any partitions that should not be
pruned. This works by creating random permutations of RANGE
partitioned tables and then inserting a small number of records to
each partition. It then runs a few queries on that partitioned table
with various WHERE clauses and checks the number of records returned
with enable_partition_pruning both on and off, then checks the number
of records is the same in each instance. This would find cases where
partitions are pruned by mistake. I hand-modified the tool to write
the EXPLAIN output to pp_fuzz.debug_output and then I compared the
output from your patched version with master and checked to ensure the
results all made sense.

Please have a look at v3 and confirm you're happy with the adjustments
I've made.

David

Attachments:

t253332_5
partprune_fuzz.sqlapplication/octet-stream; name=partprune_fuzz.sqlDownload
v3-0001-Fix-pruning-of-DEFAULT-partition-in-RANGE-partiti.patchapplication/octet-stream; name=v3-0001-Fix-pruning-of-DEFAULT-partition-in-RANGE-partiti.patchDownload+214-27
#6Ewan Young
kdbase.hack@gmail.com
In reply to: David Rowley (#5)
Re: RANGE partition pruning can still exclude the default partition

Thanks for the review and for tightening this up.

v3 looks good to me. The nvalues == 1 restriction on the first-key
MINVALUE/MAXVALUE trim is a clear improvement: the leading single-key
step already trims the default there, and the BTEqualStrategyNumber
block handles the multi-key prefixes, so the intersection removes the
default without repeating the first-key check in every step. Your
comment rewrite explains the interaction much better than my original;
agreed it was too thin.

Happy with the adjustments -- thanks for picking this up.

On Fri, Sep 18, 2026 at 4:55 AM David Rowley <dgrowleyml@gmail.com> wrote:

On Thu, 6 Aug 2026 at 22:47, Ewan Young <kdbase.hack@gmail.com> wrote:

0001 tests the first key of the bound instead of the last key of the lookup
value; the code change is two lines. I did not delete the blocks the way
709dfd27f14 did, because when the first key really is unbounded there is
nothing beyond it and removing them would scan the default partition for no
reason. Tests cover a trailing MAXVALUE, the MINVALUE mirror, a genuinely
unbounded first key, and the no-default case; the last two are unchanged by
the patch, on purpose.

0001 alone gives up one pruning opportunity: "WHERE a = 19 AND b >= 5" now
also scans the default partition. That pruning was unsound where it
happened - "WHERE a >= 19 AND b >= 5" makes the identical call (strategy

=, values (19, 5)), and there the rows above the bound do qualify; master

answers it with 2 rows where 3 is correct. The function cannot tell the
two apart.

0002 recovers it where the knowledge exists. In the equality-prefix path
the code already skips the offset below the smallest matching bound when
that bound is (prefix, MINVALUE); the mirror was missing, so a greatest
matching bound of (prefix, MAXVALUE) still pulled in the offset above it.
With 0002, "WHERE a = 19 AND b >= 5" scans t1 only, while "a >= 19 AND
b >= 5" and plain "a = 19" still scan the default partition, the latter
because a NULL in a later key is routed there. 0002 is a pruning
improvement rather than a correctness fix, hence the split.

I spent some time looking at these patches and I believe both the
changes together make sense. I feel the commentary around how all this
works is a bit lacking in general, however.

The reason to switch to only checking for MINVALUE / MAXVALUE on the
first partition key is because you've made it so the
BTEqualStrategyNumber code handles doing this for subsequent keys, and
since the step generation always generates steps with leading subsets
of the given values, the code you added to BTEqualStrategyNumber will
trim off the default when the final partition found by the
BTEqualStrategyNumber code for the leading prefix has a MAXVALUE
clause. For example, if you have a query doing "WHERE a = 19 AND b >=
5", the pruning code will generate 2 pruning steps, one for "a = 19"
and the 2nd with the full "a = 19 AND b >= 5". If there had been 3
clauses, then steps would be generated for each intermediate prefix of
the quals matching each partition key (i.e 3 pruning steps). When we
get the pruning results for the "a = 19" step, that hits the
BTEqualStrategyNumber code and because we don't have quals there for
all partition key columns, we must find all partitions that match "a =
19". There's a while loop doing that in the BTEqualStrategyNumber
case.

Because we generate steps for each combination of leading prefix of
clauses matching the partition key, the leading "a = 19" step going
through the BTEqualStrategyNumber code will detect if the final
partition we land on that matches "a = 19" has a MAXVALUE, and not
include the DEFAULT. Since the result of this step and the step
containing the quals for both keys are intersected, you only need to
prune the default partition in one of the steps for it not to appear
in the intersected result of all pruning steps.

I did modify the patch slightly so that the MINVALUE / MAXVALUE code
for the 0th partition key only executes when nvalues == 1. In the
example above, this means it only executes in the "a = 19" step and
not the "a = 19 and b >= 5" step. This doesn't make any difference to
the final result, but I think it makes more sense to do this as it
means we only apply that optimisation once rather than doing it
several times redundantly. I also tried to explain what's going on in
a paragraph of comments.

I've attached an AI-written and hand-modified fuzzing tool that I used
to check your patch doesn't prune any partitions that should not be
pruned. This works by creating random permutations of RANGE
partitioned tables and then inserting a small number of records to
each partition. It then runs a few queries on that partitioned table
with various WHERE clauses and checks the number of records returned
with enable_partition_pruning both on and off, then checks the number
of records is the same in each instance. This would find cases where
partitions are pruned by mistake. I hand-modified the tool to write
the EXPLAIN output to pp_fuzz.debug_output and then I compared the
output from your patched version with master and checked to ensure the
results all made sense.

Please have a look at v3 and confirm you're happy with the adjustments
I've made.

David

--
Regards,
Ewan Young

#7David Rowley
dgrowleyml@gmail.com
In reply to: Ewan Young (#6)
Re: RANGE partition pruning can still exclude the default partition

On Fri, 18 Sept 2026 at 15:01, Ewan Young <kdbase.hack@gmail.com> wrote:

v3 looks good to me. The nvalues == 1 restriction on the first-key
MINVALUE/MAXVALUE trim is a clear improvement: the leading single-key
step already trims the default there, and the BTEqualStrategyNumber
block handles the multi-key prefixes, so the intersection removes the
default without repeating the first-key check in every step. Your
comment rewrite explains the interaction much better than my original;
agreed it was too thin.

Happy with the adjustments -- thanks for picking this up.

OK thanks. I did a bit more work on the tests and pushed.

David