diff options
Diffstat (limited to 'src/include/partitioning/partbounds.h')
-rw-r--r-- | src/include/partitioning/partbounds.h | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/include/partitioning/partbounds.h b/src/include/partitioning/partbounds.h index 6bd330dd938..ebf3ff1f497 100644 --- a/src/include/partitioning/partbounds.h +++ b/src/include/partitioning/partbounds.h @@ -30,7 +30,7 @@ struct RelOptInfo; /* avoid including pathnodes.h here */ * In the case of range partitioning, ndatums will typically be far less than * 2 * nparts, because a partition's upper bound and the next partition's lower * bound are the same in most common cases, and we only store one of them (the - * upper bound). In case of hash partitioning, ndatums will be same as the + * upper bound). In case of hash partitioning, ndatums will be the same as the * number of partitions. * * For range and list partitioned tables, datums is an array of datum-tuples @@ -46,24 +46,31 @@ struct RelOptInfo; /* avoid including pathnodes.h here */ * the partition key's operator classes and collations. * * In the case of list partitioning, the indexes array stores one entry for - * every datum, which is the index of the partition that accepts a given datum. - * In case of range partitioning, it stores one entry per distinct range - * datum, which is the index of the partition for which a given datum - * is an upper bound. In the case of hash partitioning, the number of the - * entries in the indexes array is same as the greatest modulus amongst all - * partitions. For a given partition key datum-tuple, the index of the - * partition which would accept that datum-tuple would be given by the entry - * pointed by remainder produced when hash value of the datum-tuple is divided - * by the greatest modulus. + * each datum-array entry, which is the index of the partition that accepts + * rows matching that datum. So nindexes == ndatums. + * + * In the case of range partitioning, the indexes array stores one entry per + * distinct range datum, which is the index of the partition for which that + * datum is an upper bound (or -1 for a "gap" that has no partition). It is + * convenient to have an extra -1 entry representing values above the last + * range datum, so nindexes == ndatums + 1. + * + * In the case of hash partitioning, the number of entries in the indexes + * array is the same as the greatest modulus amongst all partitions (which + * is a multiple of all partition moduli), so nindexes == greatest modulus. + * The indexes array is indexed according to the hash key's remainder modulo + * the greatest modulus, and it contains either the partition index accepting + * that remainder, or -1 if there is no partition for that remainder. */ typedef struct PartitionBoundInfoData { char strategy; /* hash, list or range? */ - int ndatums; /* Length of the datums following array */ + int ndatums; /* Length of the datums[] array */ Datum **datums; PartitionRangeDatumKind **kind; /* The kind of each range bound datum; * NULL for hash and list partitioned * tables */ + int nindexes; /* Length of the indexes[] array */ int *indexes; /* Partition indexes */ int null_index; /* Index of the null-accepting partition; -1 * if there isn't one */ |