Hi! I reviewed v7. Maybe we should add a multi-level partitioning case into copy2.sql regression test?
I also did quick benchmarking for this patch: ==== DDL create table ppp(i int) partition by range (i); genddl.sh: for i in `seq 0 200`; do echo "create table p$i partition of ppp for values from ( $((10 * i)) ) to ( $((10 * (i + 1))) ); "; done === insert data data: insert into ppp select i / 1000 from generate_series(0, 2000000)i; === results: for 2000001 rows speedup is 1.40 times : 902.604 ms (patches) vs 1270.648 ms (unpatched) for 4000002 rows speedup is 1.20 times : 1921.724 ms (patches) vs 2343.393 ms (unpatched) for 8000004 rows speedup is 1.10 times : 3932.361 ms (patches) vs 4358.489ms (unpatched) So, this patch indeed speeds up some cases, but with larger tables speedup becomes negligible. -- Best regards, Kirill Reshke