From 971d7ddbe19ad9525457e65d01b8b6504ab57cc4 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Sat, 7 Apr 2018 10:35:38 -0300 Subject: [PATCH] Document partprune.c a little better MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Author: Amit Langote Reviewed-by: Álvaro Herrera, David Rowley Discussion: https://postgr.es/m/CA+HiwqGzq4D6z=8R0AP+XhbTFCQ-4Ct+t2ekqjE9Fpm84_JUGg@mail.gmail.com --- src/backend/partitioning/partprune.c | 29 +++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/backend/partitioning/partprune.c b/src/backend/partitioning/partprune.c index 959ee1643d..e70770e7b3 100644 --- a/src/backend/partitioning/partprune.c +++ b/src/backend/partitioning/partprune.c @@ -1,10 +1,28 @@ /*------------------------------------------------------------------------- * * partprune.c - * Parses clauses attempting to match them up to partition keys of a - * given relation and generates a set of "pruning steps", which can be - * later "executed" either from the planner or the executor to determine - * the minimum set of partitions which match the given clauses. + * Support for partition pruning during query planning + * + * This module implements partition pruning using the information contained in + * table's partition descriptor and query clauses. + * + * During planning, clauses that can be matched to the table's partition key + * are turned into a set of "pruning steps", which are then executed to + * produce a set of partitions (as indexes of the RelOptInfo->part_rels array) + * that satisfy the constraints in the step Partitions not in the set are said + * to have been pruned. + * + * There are two kinds of pruning steps: a "base" pruning step, which contains + * information extracted from one or more clauses that are matched to the + * (possibly multi-column) partition key, such as the expressions whose values + * to match against partition bounds and operator strategy to associate to + * each expression. The other kind is a "combine" pruning step, which combines + * the outputs of some other steps using the appropriate combination method. + * All steps that are constructed are executed in succession such that for any + * "combine" step, all of the steps whose output it depends on are executed + * first and their ouput preserved. + * + * See gen_partprune_steps_internal() for more details on step generation. * * Portions Copyright (c) 1996-2018, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California @@ -256,7 +274,8 @@ prune_append_rel_partitions(RelOptInfo *rel) * get_matching_partitions * Determine partitions that survive partition pruning * - * Returns a Bitmapset of indexes of surviving partitions. + * Returns a Bitmapset of the RelOptInfo->part_rels indexes of the surviving + * partitions. */ Bitmapset * get_matching_partitions(PartitionPruneContext *context, List *pruning_steps) -- 2.40.0