From 475dbd0b718de8ac44da144f934651b959e3b705 Mon Sep 17 00:00:00 2001 From: David Rowley Date: Tue, 3 Aug 2021 11:47:24 +1200 Subject: Track a Bitmapset of non-pruned partitions in RelOptInfo For partitioned tables with large numbers of partitions where queries are able to prune all but a very small number of partitions, the time spent in the planner looping over RelOptInfo.part_rels checking for non-NULL RelOptInfos could become a large portion of the overall planning time. Here we add a Bitmapset that records the non-pruned partitions. This allows us to more efficiently skip the pruned partitions by looping over the Bitmapset. This will cause a very slight slow down in cases where no or not many partitions could be pruned, however, those cases are already slow to plan anyway and the overhead of looping over the Bitmapset would be unmeasurable when compared with the other tasks such as path creation for a large number of partitions. Reviewed-by: Amit Langote, Zhihong Yu Discussion: https://postgr.es/m/CAApHDvqnPx6JnUuPwaf5ao38zczrAb9mxt9gj4U1EKFfd4AqLA@mail.gmail.com --- src/backend/nodes/outfuncs.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/backend/nodes/outfuncs.c') diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 48202d22320..87561cbb6f1 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -2386,6 +2386,7 @@ _outRelOptInfo(StringInfo str, const RelOptInfo *node) WRITE_BOOL_FIELD(consider_partitionwise_join); WRITE_BITMAPSET_FIELD(top_parent_relids); WRITE_BOOL_FIELD(partbounds_merged); + WRITE_BITMAPSET_FIELD(live_parts); WRITE_BITMAPSET_FIELD(all_partrels); } -- cgit v1.2.3