Repository navigation
Description
Bug or Feature Request
Bug
Description
Partition pruning does not happen — queries on partitioned tables scan ALL partitions, even when the WHERE clause pins the partition key to a single partition. Partitioned tables in MatrixOne provide data routing (rows do land in the correct partition sub-tables, verified) but none of the read-path performance benefit of partitioning, because every scan touches every partition. Partition pruning has been an advertised capability since the 1.1.0 release notes ("支持 Key,hash 的分区裁剪能力"; RANGE/LIST partitioning also listed), so the current behavior regresses / fails to deliver a documented feature.
Hard evidence via EXPLAIN ANALYZE (300k-row RANGE-partitioned table, v3.x @ b24d1b3)
Setup:
CREATE TABLE bigp (id BIGINT, dt DATE)
PARTITION BY RANGE (year(dt)) (
PARTITION p1 VALUES LESS THAN (2015),
PARTITION p2 VALUES LESS THAN (2020),
PARTITION p3 VALUES LESS THAN (MAXVALUE)
);
-- 300,000 rows spanning years 2010-2024; distribution verified in physical partition
-- sub-tables: p1=100,053 p2=99,851 p3=100,096Query pinning the partition key to exactly partition p1 (year 2010 ⊂ [2010, 2015)):
EXPLAIN ANALYZE SELECT count(*) FROM bigp WHERE dt BETWEEN '2010-01-01' AND '2010-12-31';Actual plan shows the parent scan reads the entire table:
-> Table Scan on part.bigp
Analyze: ... inputBlocks=54 inputRows=300000 outputRows=19620 ...
inputRows=300000 — all three partitions (~2/3 of the data in p2+p3 can never qualify: 2010 rows only exist in p1) are read and then filtered away.
Direct control — querying the physical partition sub-table part.%!%p1%!%bigp`` with the same predicate:
-> Table Scan on part.%!%p1%!%bigp
Analyze: ... inputRows=100053 outputRows=19620 ...
(One partition: 100k rows scan instead of 300k, same output. The pruning engine literally has a 3× saving on the table and takes 0.)
Other probe results:
| Query | Table Scan inputRows | Should be (with pruning) |
|---|---|---|
WHERE year(dt) = 2010 on bigp |
300000 | 100053 (p1 only) |
WHERE dt BETWEEN '2010-01-01' AND '2010-12-31' on bigp |
300000 | 100053 |
| no filter on bigp | 300000 | 300000 (correctly) |
same predicate on hidden %!%p1%!%bigp |
100053 | — |
LIST partitioning behaves the same (2-row table, WHERE c='a' still reads both pa and pb partitions — inputRows=2). EXPLAIN PARTITIONS (MySQL syntax for showing pruned partitions) returns empty output — no partition-level plan info exists at all, so users cannot even see which partitions are visited.
Impact
Partitioning in MO currently costs (extra DDL complexity + partition-subtable catalog clutter, visible as %!%p<name>%!%<table> rows in mo_catalog.mo_tables which also confuse SHOW TABLES-style tooling) while delivering none of the advertised query-time benefit. For a time-partitioned table with years of cold data, a hot-partition query reads N× more rows than necessary — the primary use-case of partitioning is silently defeated.
Positive notes (what does work — scoping the bug to the read path)
- Data routing is correct: inserts land in the right physical partition sub-tables (row counts 100053/99851/100096 match year distribution exactly).
- Cross-partition PRIMARY KEY uniqueness is enforced correctly (inserting a duplicate PK landing in another partition still raises 1062) — actually stronger than MySQL's own semantics, which would require the partition key inside the PK.
SHOW CREATE TABLEround-trips the fullPARTITION BYclause.
Steps to Reproduce
- Create the RANGE-partitioned table above, load ~300k rows spanning the partition bounds.
- Run
EXPLAIN ANALYZE SELECT count(*) FROM bigp WHERE dt BETWEEN '2010-01-01' AND '2010-12-31'; - Observe
inputRows=300000on the parentTable Scan on part.bigp— no pruning to p1. - Cross-check by querying
mo_catalog.mo_tablesfor hidden partitions of the table and comparing read sizes.
Expected behavior
For predicates on the partition expression (RANGE/LIST: interval and point comparisons; HASH/KEY: point equality), the planner should restrict the scan to the qualifying physical partition sub-tables (or expose block-level pruning that is partition-aware). At minimum, the documented Key/hash pruning capability should work, and EXPLAIN should identify accessed partitions (EXPLAIN PARTITIONS semantics).
Versions
- MatrixOne commit
b24d1b3(2026-10-16), v3.x dev, macOS arm64, single-node launch - Partition types tested: RANGE (year(col)), LIST (col), HASH(col) PARTITIONS 4
Additional context
- Official 1.1.0 release notes advertised partition pruning (Key/hash beta) and RANGE/LIST support — the finding here is that in the tested build none of the three partition types prune.
- Related observation for a later sweep: hidden partition sub-tables appear in
mo_catalog.mo_tableswith raw names like%!%p1%!%bigp, andmo_tables.partition_infofor the parent returns binary garbage in text protocol — tooling that joins this catalog view gets unusable output.
Activity