CREATE OR REPLACE TABLE probe_kK (s VARCHAR) AS
SELECT REPEAT('A', K-1) || TO_CHAR(SEQ8())
FROM TABLE(GENERATOR(ROWCOUNT => 500000000))
ORDER BY 1;
SET probe = (SELECT s FROM probe_kK SAMPLE (1 ROWS));
SELECT COUNT(*) FROM probe_kK WHERE s = $probe;
SELECT operator_statistics:pruning:partitions_scanned::INT AS scanned,
operator_statistics:pruning:partitions_total::INT AS total
FROM TABLE(GET_QUERY_OPERATOR_STATS(LAST_QUERY_ID(-1)))
WHERE operator_type = 'TableScan';| K | Scan part/Total Part | pct | pruning |
|---|---|---|---|
| 32 | 2 / 16 | 12.5% | ✅ |
| 33 | 15 / 16 | 93.8% | ❌ |
| 34 | 15 / 16 | 93.8% | ❌ |
| 36 | 15 / 16 | 93.8% | ❌ |
| 40 | 22 / 23 | 95.7% | ❌ |
Use Chinese char
| table | prefix | Distinguish character positions | Distinguish byte positions | Scan / Total | pct | pruning |
|---|---|---|---|---|---|---|
| probe_mb6 | 中×5 + SEQ8 |
char6 | byte16 | 1 / 16 | 6.3% | ✅ |
| probe_mb11 | 中×10 + SEQ8 |
char11 | byte31 | 2 / 16 | 12.5% | ✅ |
| probe_bx31 | 中×10 + 'A' + SEQ8 |
char12 | byte32 | 1 / 16 | 6.3% | ✅ |
| probe_bx32 | 中×10 + 'AA' + SEQ8 |
char13 | byte33 | 15 / 16 | 93.8% | ❌ |
| probe_mb12 | 中×11 + SEQ8 |
char12 | byte34 | 16 / 16 | 100% | ❌ |
| probe_mb33 | 中×32 + SEQ8 |
char33 | byte97 | 22 / 24 | 91.7% | ❌ |
- If two rows first differ within the first ≤32 bytes → partition min/max values are distinguishable → pruning works.
- If they first differ at byte ≥33 → all partitions share the same first 32 bytes in their min/max → no pruning → near full-table scan
Measured on Snowflake 10.25.101. Corrections welcome.