mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Add hash partitioning.
Hash partitioning is useful when you want to partition a growing data set evenly. This can be useful to keep table sizes reasonable, which makes maintenance operations such as VACUUM faster, or to enable partition-wise join. At present, we still depend on constraint exclusion for partitioning pruning, and the shape of the partition constraints for hash partitioning is such that that doesn't work. Work is underway to fix that, which should both improve performance and make partitioning pruning work with hash partitioning. Amul Sul, reviewed and tested by Dilip Kumar, Ashutosh Bapat, Yugo Nagata, Rajkumar Raghuwanshi, Jesper Pedersen, and by me. A few final tweaks also by me. Discussion: http://postgr.es/m/CAAJ_b96fhpJAP=ALbETmeLk1Uni_GFZD938zgenhF49qgDTjaQ@mail.gmail.com
This commit is contained in:
@ -1463,7 +1463,7 @@ have_partkey_equi_join(RelOptInfo *rel1, RelOptInfo *rel2, JoinType jointype,
|
||||
continue;
|
||||
|
||||
/* Skip clauses which are not equality conditions. */
|
||||
if (!rinfo->mergeopfamilies)
|
||||
if (!rinfo->mergeopfamilies && !OidIsValid(rinfo->hashjoinoperator))
|
||||
continue;
|
||||
|
||||
opexpr = (OpExpr *) rinfo->clause;
|
||||
@ -1515,8 +1515,14 @@ have_partkey_equi_join(RelOptInfo *rel1, RelOptInfo *rel2, JoinType jointype,
|
||||
* The clause allows partition-wise join if only it uses the same
|
||||
* operator family as that specified by the partition key.
|
||||
*/
|
||||
if (!list_member_oid(rinfo->mergeopfamilies,
|
||||
part_scheme->partopfamily[ipk1]))
|
||||
if (rel1->part_scheme->strategy == PARTITION_STRATEGY_HASH)
|
||||
{
|
||||
if (!op_in_opfamily(rinfo->hashjoinoperator,
|
||||
part_scheme->partopfamily[ipk1]))
|
||||
continue;
|
||||
}
|
||||
else if (!list_member_oid(rinfo->mergeopfamilies,
|
||||
part_scheme->partopfamily[ipk1]))
|
||||
continue;
|
||||
|
||||
/* Mark the partition key as having an equi-join clause. */
|
||||
|
Reference in New Issue
Block a user