[question] multil-column range partition prune - Mailing list pgsql-hackers

From tender wang
Subject [question] multil-column range partition prune
Date
Msg-id CAHewXNkpULo0ipTJCydNE0-oT2Xnh+BSMzBy+rgthNegSdKY8w@mail.gmail.com
Whole thread Raw
Responses Re: [question] multil-column range partition prune
Re: [question] multil-column range partition prune
List pgsql-hackers
I have an range partition and query below:
create table p_range(a int, b int) partition by range (a,b); create table p_range1 partition of p_range for values from (1,1) to (3,3); create table p_range2 partition of p_range for values from (4,4) to (6,6); explain select * from p_range where b =2;
                                QUERY PLAN
--------------------------------------------------------------------------
 Append  (cost=0.00..76.61 rows=22 width=8)
   ->  Seq Scan on p_range1 p_range_1  (cost=0.00..38.25 rows=11 width=8)
         Filter: (b = 2)
   ->  Seq Scan on p_range2 p_range_2  (cost=0.00..38.25 rows=11 width=8)
         Filter: (b = 2)
(5 rows)

The result of EXPLAIN shows that no partition prune happened.
And gen_prune_steps_from_opexps() has comments that can answer the result.
/*
* For range partitioning, if we have no clauses for the current key,
* we can't consider any later keys either, so we can stop here.
*/
if (part_scheme->strategy == PARTITION_STRATEGY_RANGE &&
clauselist == NIL)
break;

But I want to know why we don't prune when just have latter partition key in whereClause.
Thanks.

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: pgsql: Ignore BRIN indexes when checking for HOT udpates
Next
From: Amit Kapila
Date:
Subject: Re: [PATCH] Add loongarch native checksum implementation.