Rename enable_partition_wise_join to enable_partitionwise_join
Discussion: https://www.postgresql.org/message-id/flat/ad24e4f4-6481-066e-e3fb-6ef4a3121882%402ndquadrant.com
This commit is contained in:
parent
f8437c819a
commit
2fb1abaeb0
|
@ -7682,9 +7682,9 @@ AND ftoptions @> array['fetch_size=60000'];
|
||||||
|
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
-- test partition-wise-joins
|
-- test partitionwise joins
|
||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
SET enable_partition_wise_join=on;
|
SET enable_partitionwise_join=on;
|
||||||
CREATE TABLE fprt1 (a int, b int, c varchar) PARTITION BY RANGE(a);
|
CREATE TABLE fprt1 (a int, b int, c varchar) PARTITION BY RANGE(a);
|
||||||
CREATE TABLE fprt1_p1 (LIKE fprt1);
|
CREATE TABLE fprt1_p1 (LIKE fprt1);
|
||||||
CREATE TABLE fprt1_p2 (LIKE fprt1);
|
CREATE TABLE fprt1_p2 (LIKE fprt1);
|
||||||
|
@ -7800,4 +7800,4 @@ SELECT t1.a,t1.b FROM fprt1 t1, LATERAL (SELECT t2.a, t2.b FROM fprt2 t2 WHERE t
|
||||||
400 | 400
|
400 | 400
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
RESET enable_partition_wise_join;
|
RESET enable_partitionwise_join;
|
||||||
|
|
|
@ -1863,9 +1863,9 @@ AND ftoptions @> array['fetch_size=60000'];
|
||||||
ROLLBACK;
|
ROLLBACK;
|
||||||
|
|
||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
-- test partition-wise-joins
|
-- test partitionwise joins
|
||||||
-- ===================================================================
|
-- ===================================================================
|
||||||
SET enable_partition_wise_join=on;
|
SET enable_partitionwise_join=on;
|
||||||
|
|
||||||
CREATE TABLE fprt1 (a int, b int, c varchar) PARTITION BY RANGE(a);
|
CREATE TABLE fprt1 (a int, b int, c varchar) PARTITION BY RANGE(a);
|
||||||
CREATE TABLE fprt1_p1 (LIKE fprt1);
|
CREATE TABLE fprt1_p1 (LIKE fprt1);
|
||||||
|
@ -1913,4 +1913,4 @@ EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a,t1.b FROM fprt1 t1, LATERAL (SELECT t2.a, t2.b FROM fprt2 t2 WHERE t1.a = t2.b AND t1.b = t2.a) q WHERE t1.a%25 = 0 ORDER BY 1,2;
|
SELECT t1.a,t1.b FROM fprt1 t1, LATERAL (SELECT t2.a, t2.b FROM fprt2 t2 WHERE t1.a = t2.b AND t1.b = t2.a) q WHERE t1.a%25 = 0 ORDER BY 1,2;
|
||||||
SELECT t1.a,t1.b FROM fprt1 t1, LATERAL (SELECT t2.a, t2.b FROM fprt2 t2 WHERE t1.a = t2.b AND t1.b = t2.a) q WHERE t1.a%25 = 0 ORDER BY 1,2;
|
SELECT t1.a,t1.b FROM fprt1 t1, LATERAL (SELECT t2.a, t2.b FROM fprt2 t2 WHERE t1.a = t2.b AND t1.b = t2.a) q WHERE t1.a%25 = 0 ORDER BY 1,2;
|
||||||
|
|
||||||
RESET enable_partition_wise_join;
|
RESET enable_partitionwise_join;
|
||||||
|
|
|
@ -3736,20 +3736,20 @@ ANY <replaceable class="parameter">num_sync</replaceable> ( <replaceable class="
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
<varlistentry id="guc-enable-partition-wise-join" xreflabel="enable_partition_wise_join">
|
<varlistentry id="guc-enable-partitionwise-join" xreflabel="enable_partitionwise_join">
|
||||||
<term><varname>enable_partition_wise_join</varname> (<type>boolean</type>)
|
<term><varname>enable_partitionwise_join</varname> (<type>boolean</type>)
|
||||||
<indexterm>
|
<indexterm>
|
||||||
<primary><varname>enable_partition_wise_join</varname> configuration parameter</primary>
|
<primary><varname>enable_partitionwise_join</varname> configuration parameter</primary>
|
||||||
</indexterm>
|
</indexterm>
|
||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Enables or disables the query planner's use of partition-wise join,
|
Enables or disables the query planner's use of partitionwise join,
|
||||||
which allows a join between partitioned tables to be performed by
|
which allows a join between partitioned tables to be performed by
|
||||||
joining the matching partitions. Partition-wise join currently applies
|
joining the matching partitions. Partitionwise join currently applies
|
||||||
only when the join conditions include all the partition keys, which
|
only when the join conditions include all the partition keys, which
|
||||||
must be of the same data type and have exactly matching sets of child
|
must be of the same data type and have exactly matching sets of child
|
||||||
partitions. Because partition-wise join planning can use significantly
|
partitions. Because partitionwise join planning can use significantly
|
||||||
more CPU time and memory during planning, the default is
|
more CPU time and memory during planning, the default is
|
||||||
<literal>off</literal>.
|
<literal>off</literal>.
|
||||||
</para>
|
</para>
|
||||||
|
|
|
@ -1076,8 +1076,8 @@ plan as possible. Expanding the range of cases in which more work can be
|
||||||
pushed below the Gather (and costing them accurately) is likely to keep us
|
pushed below the Gather (and costing them accurately) is likely to keep us
|
||||||
busy for a long time to come.
|
busy for a long time to come.
|
||||||
|
|
||||||
Partition-wise joins
|
Partitionwise joins
|
||||||
--------------------
|
-------------------
|
||||||
A join between two similarly partitioned tables can be broken down into joins
|
A join between two similarly partitioned tables can be broken down into joins
|
||||||
between their matching partitions if there exists an equi-join condition
|
between their matching partitions if there exists an equi-join condition
|
||||||
between the partition keys of the joining tables. The equi-join between
|
between the partition keys of the joining tables. The equi-join between
|
||||||
|
@ -1089,7 +1089,7 @@ partitioned in the same way as the joining relations, thus allowing an N-way
|
||||||
join between similarly partitioned tables having equi-join condition between
|
join between similarly partitioned tables having equi-join condition between
|
||||||
their partition keys to be broken down into N-way joins between their matching
|
their partition keys to be broken down into N-way joins between their matching
|
||||||
partitions. This technique of breaking down a join between partitioned tables
|
partitions. This technique of breaking down a join between partitioned tables
|
||||||
into joins between their partitions is called partition-wise join. We will use
|
into joins between their partitions is called partitionwise join. We will use
|
||||||
term "partitioned relation" for either a partitioned table or a join between
|
term "partitioned relation" for either a partitioned table or a join between
|
||||||
compatibly partitioned tables.
|
compatibly partitioned tables.
|
||||||
|
|
||||||
|
|
|
@ -264,8 +264,8 @@ merge_clump(PlannerInfo *root, List *clumps, Clump *new_clump, bool force)
|
||||||
/* Keep searching if join order is not valid */
|
/* Keep searching if join order is not valid */
|
||||||
if (joinrel)
|
if (joinrel)
|
||||||
{
|
{
|
||||||
/* Create paths for partition-wise joins. */
|
/* Create paths for partitionwise joins. */
|
||||||
generate_partition_wise_join_paths(root, joinrel);
|
generate_partitionwise_join_paths(root, joinrel);
|
||||||
|
|
||||||
/* Create GatherPaths for any useful partial paths for rel */
|
/* Create GatherPaths for any useful partial paths for rel */
|
||||||
generate_gather_paths(root, joinrel);
|
generate_gather_paths(root, joinrel);
|
||||||
|
|
|
@ -929,7 +929,7 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
|
||||||
/*
|
/*
|
||||||
* We need attr_needed data for building targetlist of a join
|
* We need attr_needed data for building targetlist of a join
|
||||||
* relation representing join between matching partitions for
|
* relation representing join between matching partitions for
|
||||||
* partition-wise join. A given attribute of a child will be
|
* partitionwise join. A given attribute of a child will be
|
||||||
* needed in the same highest joinrel where the corresponding
|
* needed in the same highest joinrel where the corresponding
|
||||||
* attribute of parent is needed. Hence it suffices to use the
|
* attribute of parent is needed. Hence it suffices to use the
|
||||||
* same Relids set for parent and child.
|
* same Relids set for parent and child.
|
||||||
|
@ -973,7 +973,7 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
|
||||||
/*
|
/*
|
||||||
* Copy/Modify targetlist. Even if this child is deemed empty, we need
|
* Copy/Modify targetlist. Even if this child is deemed empty, we need
|
||||||
* its targetlist in case it falls on nullable side in a child-join
|
* its targetlist in case it falls on nullable side in a child-join
|
||||||
* because of partition-wise join.
|
* because of partitionwise join.
|
||||||
*
|
*
|
||||||
* NB: the resulting childrel->reltarget->exprs may contain arbitrary
|
* NB: the resulting childrel->reltarget->exprs may contain arbitrary
|
||||||
* expressions, which otherwise would not occur in a rel's targetlist.
|
* expressions, which otherwise would not occur in a rel's targetlist.
|
||||||
|
@ -2636,7 +2636,7 @@ standard_join_search(PlannerInfo *root, int levels_needed, List *initial_rels)
|
||||||
join_search_one_level(root, lev);
|
join_search_one_level(root, lev);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Run generate_partition_wise_join_paths() and
|
* Run generate_partitionwise_join_paths() and
|
||||||
* generate_gather_paths() for each just-processed joinrel. We could
|
* generate_gather_paths() for each just-processed joinrel. We could
|
||||||
* not do this earlier because both regular and partial paths can get
|
* not do this earlier because both regular and partial paths can get
|
||||||
* added to a particular joinrel at multiple times within
|
* added to a particular joinrel at multiple times within
|
||||||
|
@ -2649,8 +2649,8 @@ standard_join_search(PlannerInfo *root, int levels_needed, List *initial_rels)
|
||||||
{
|
{
|
||||||
rel = (RelOptInfo *) lfirst(lc);
|
rel = (RelOptInfo *) lfirst(lc);
|
||||||
|
|
||||||
/* Create paths for partition-wise joins. */
|
/* Create paths for partitionwise joins. */
|
||||||
generate_partition_wise_join_paths(root, rel);
|
generate_partitionwise_join_paths(root, rel);
|
||||||
|
|
||||||
/* Create GatherPaths for any useful partial paths for rel */
|
/* Create GatherPaths for any useful partial paths for rel */
|
||||||
generate_gather_paths(root, rel);
|
generate_gather_paths(root, rel);
|
||||||
|
@ -3405,8 +3405,8 @@ compute_parallel_worker(RelOptInfo *rel, double heap_pages, double index_pages,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* generate_partition_wise_join_paths
|
* generate_partitionwise_join_paths
|
||||||
* Create paths representing partition-wise join for given partitioned
|
* Create paths representing partitionwise join for given partitioned
|
||||||
* join relation.
|
* join relation.
|
||||||
*
|
*
|
||||||
* This must not be called until after we are done adding paths for all
|
* This must not be called until after we are done adding paths for all
|
||||||
|
@ -3414,7 +3414,7 @@ compute_parallel_worker(RelOptInfo *rel, double heap_pages, double index_pages,
|
||||||
* generated here has a reference.
|
* generated here has a reference.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
generate_partition_wise_join_paths(PlannerInfo *root, RelOptInfo *rel)
|
generate_partitionwise_join_paths(PlannerInfo *root, RelOptInfo *rel)
|
||||||
{
|
{
|
||||||
List *live_children = NIL;
|
List *live_children = NIL;
|
||||||
int cnt_parts;
|
int cnt_parts;
|
||||||
|
@ -3442,8 +3442,8 @@ generate_partition_wise_join_paths(PlannerInfo *root, RelOptInfo *rel)
|
||||||
|
|
||||||
Assert(child_rel != NULL);
|
Assert(child_rel != NULL);
|
||||||
|
|
||||||
/* Add partition-wise join paths for partitioned child-joins. */
|
/* Add partitionwise join paths for partitioned child-joins. */
|
||||||
generate_partition_wise_join_paths(root, child_rel);
|
generate_partitionwise_join_paths(root, child_rel);
|
||||||
|
|
||||||
/* Dummy children will not be scanned, so ignore those. */
|
/* Dummy children will not be scanned, so ignore those. */
|
||||||
if (IS_DUMMY_REL(child_rel))
|
if (IS_DUMMY_REL(child_rel))
|
||||||
|
|
|
@ -127,7 +127,7 @@ bool enable_material = true;
|
||||||
bool enable_mergejoin = true;
|
bool enable_mergejoin = true;
|
||||||
bool enable_hashjoin = true;
|
bool enable_hashjoin = true;
|
||||||
bool enable_gathermerge = true;
|
bool enable_gathermerge = true;
|
||||||
bool enable_partition_wise_join = false;
|
bool enable_partitionwise_join = false;
|
||||||
bool enable_parallel_append = true;
|
bool enable_parallel_append = true;
|
||||||
bool enable_parallel_hash = true;
|
bool enable_parallel_hash = true;
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ static bool restriction_is_constant_false(List *restrictlist,
|
||||||
static void populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
|
static void populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
|
||||||
RelOptInfo *rel2, RelOptInfo *joinrel,
|
RelOptInfo *rel2, RelOptInfo *joinrel,
|
||||||
SpecialJoinInfo *sjinfo, List *restrictlist);
|
SpecialJoinInfo *sjinfo, List *restrictlist);
|
||||||
static void try_partition_wise_join(PlannerInfo *root, RelOptInfo *rel1,
|
static void try_partitionwise_join(PlannerInfo *root, RelOptInfo *rel1,
|
||||||
RelOptInfo *rel2, RelOptInfo *joinrel,
|
RelOptInfo *rel2, RelOptInfo *joinrel,
|
||||||
SpecialJoinInfo *parent_sjinfo,
|
SpecialJoinInfo *parent_sjinfo,
|
||||||
List *parent_restrictlist);
|
List *parent_restrictlist);
|
||||||
|
@ -903,8 +903,8 @@ populate_joinrel_with_paths(PlannerInfo *root, RelOptInfo *rel1,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Apply partition-wise join technique, if possible. */
|
/* Apply partitionwise join technique, if possible. */
|
||||||
try_partition_wise_join(root, rel1, rel2, joinrel, sjinfo, restrictlist);
|
try_partitionwise_join(root, rel1, rel2, joinrel, sjinfo, restrictlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1286,25 +1286,25 @@ restriction_is_constant_false(List *restrictlist, bool only_pushed_down)
|
||||||
/*
|
/*
|
||||||
* Assess whether join between given two partitioned relations can be broken
|
* Assess whether join between given two partitioned relations can be broken
|
||||||
* down into joins between matching partitions; a technique called
|
* down into joins between matching partitions; a technique called
|
||||||
* "partition-wise join"
|
* "partitionwise join"
|
||||||
*
|
*
|
||||||
* Partition-wise join is possible when a. Joining relations have same
|
* Partitionwise join is possible when a. Joining relations have same
|
||||||
* partitioning scheme b. There exists an equi-join between the partition keys
|
* partitioning scheme b. There exists an equi-join between the partition keys
|
||||||
* of the two relations.
|
* of the two relations.
|
||||||
*
|
*
|
||||||
* Partition-wise join is planned as follows (details: optimizer/README.)
|
* Partitionwise join is planned as follows (details: optimizer/README.)
|
||||||
*
|
*
|
||||||
* 1. Create the RelOptInfos for joins between matching partitions i.e
|
* 1. Create the RelOptInfos for joins between matching partitions i.e
|
||||||
* child-joins and add paths to them.
|
* child-joins and add paths to them.
|
||||||
*
|
*
|
||||||
* 2. Construct Append or MergeAppend paths across the set of child joins.
|
* 2. Construct Append or MergeAppend paths across the set of child joins.
|
||||||
* This second phase is implemented by generate_partition_wise_join_paths().
|
* This second phase is implemented by generate_partitionwise_join_paths().
|
||||||
*
|
*
|
||||||
* The RelOptInfo, SpecialJoinInfo and restrictlist for each child join are
|
* The RelOptInfo, SpecialJoinInfo and restrictlist for each child join are
|
||||||
* obtained by translating the respective parent join structures.
|
* obtained by translating the respective parent join structures.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
try_partition_wise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
|
try_partitionwise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
|
||||||
RelOptInfo *joinrel, SpecialJoinInfo *parent_sjinfo,
|
RelOptInfo *joinrel, SpecialJoinInfo *parent_sjinfo,
|
||||||
List *parent_restrictlist)
|
List *parent_restrictlist)
|
||||||
{
|
{
|
||||||
|
@ -1334,7 +1334,7 @@ try_partition_wise_join(PlannerInfo *root, RelOptInfo *rel1, RelOptInfo *rel2,
|
||||||
joinrel->part_scheme == rel2->part_scheme);
|
joinrel->part_scheme == rel2->part_scheme);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Since we allow partition-wise join only when the partition bounds of
|
* Since we allow partitionwise join only when the partition bounds of
|
||||||
* the joining relations exactly match, the partition bounds of the join
|
* the joining relations exactly match, the partition bounds of the join
|
||||||
* should match those of the joining relations.
|
* should match those of the joining relations.
|
||||||
*/
|
*/
|
||||||
|
@ -1478,7 +1478,7 @@ have_partkey_equi_join(RelOptInfo *rel1, RelOptInfo *rel2, JoinType jointype,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only clauses referencing the partition keys are useful for
|
* Only clauses referencing the partition keys are useful for
|
||||||
* partition-wise join.
|
* partitionwise join.
|
||||||
*/
|
*/
|
||||||
ipk1 = match_expr_to_partition_keys(expr1, rel1, strict_op);
|
ipk1 = match_expr_to_partition_keys(expr1, rel1, strict_op);
|
||||||
if (ipk1 < 0)
|
if (ipk1 < 0)
|
||||||
|
@ -1489,13 +1489,13 @@ have_partkey_equi_join(RelOptInfo *rel1, RelOptInfo *rel2, JoinType jointype,
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the clause refers to keys at different ordinal positions, it can
|
* If the clause refers to keys at different ordinal positions, it can
|
||||||
* not be used for partition-wise join.
|
* not be used for partitionwise join.
|
||||||
*/
|
*/
|
||||||
if (ipk1 != ipk2)
|
if (ipk1 != ipk2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The clause allows partition-wise join if only it uses the same
|
* The clause allows partitionwise join if only it uses the same
|
||||||
* operator family as that specified by the partition key.
|
* operator family as that specified by the partition key.
|
||||||
*/
|
*/
|
||||||
if (rel1->part_scheme->strategy == PARTITION_STRATEGY_HASH)
|
if (rel1->part_scheme->strategy == PARTITION_STRATEGY_HASH)
|
||||||
|
|
|
@ -1601,15 +1601,15 @@ build_joinrel_partition_info(RelOptInfo *joinrel, RelOptInfo *outer_rel,
|
||||||
int cnt;
|
int cnt;
|
||||||
PartitionScheme part_scheme;
|
PartitionScheme part_scheme;
|
||||||
|
|
||||||
/* Nothing to do if partition-wise join technique is disabled. */
|
/* Nothing to do if partitionwise join technique is disabled. */
|
||||||
if (!enable_partition_wise_join)
|
if (!enable_partitionwise_join)
|
||||||
{
|
{
|
||||||
Assert(!IS_PARTITIONED_REL(joinrel));
|
Assert(!IS_PARTITIONED_REL(joinrel));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We can only consider this join as an input to further partition-wise
|
* We can only consider this join as an input to further partitionwise
|
||||||
* joins if (a) the input relations are partitioned, (b) the partition
|
* joins if (a) the input relations are partitioned, (b) the partition
|
||||||
* schemes match, and (c) we can identify an equi-join between the
|
* schemes match, and (c) we can identify an equi-join between the
|
||||||
* partition keys. Note that if it were possible for
|
* partition keys. Note that if it were possible for
|
||||||
|
|
|
@ -914,11 +914,11 @@ static struct config_bool ConfigureNamesBool[] =
|
||||||
NULL, NULL, NULL
|
NULL, NULL, NULL
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
{"enable_partition_wise_join", PGC_USERSET, QUERY_TUNING_METHOD,
|
{"enable_partitionwise_join", PGC_USERSET, QUERY_TUNING_METHOD,
|
||||||
gettext_noop("Enables partition-wise join."),
|
gettext_noop("Enables partitionwise join."),
|
||||||
NULL
|
NULL
|
||||||
},
|
},
|
||||||
&enable_partition_wise_join,
|
&enable_partitionwise_join,
|
||||||
false,
|
false,
|
||||||
NULL, NULL, NULL
|
NULL, NULL, NULL
|
||||||
},
|
},
|
||||||
|
|
|
@ -303,7 +303,7 @@
|
||||||
#enable_seqscan = on
|
#enable_seqscan = on
|
||||||
#enable_sort = on
|
#enable_sort = on
|
||||||
#enable_tidscan = on
|
#enable_tidscan = on
|
||||||
#enable_partition_wise_join = off
|
#enable_partitionwise_join = off
|
||||||
#enable_parallel_hash = on
|
#enable_parallel_hash = on
|
||||||
|
|
||||||
# - Planner Cost Constants -
|
# - Planner Cost Constants -
|
||||||
|
|
|
@ -67,7 +67,7 @@ extern PGDLLIMPORT bool enable_material;
|
||||||
extern PGDLLIMPORT bool enable_mergejoin;
|
extern PGDLLIMPORT bool enable_mergejoin;
|
||||||
extern PGDLLIMPORT bool enable_hashjoin;
|
extern PGDLLIMPORT bool enable_hashjoin;
|
||||||
extern PGDLLIMPORT bool enable_gathermerge;
|
extern PGDLLIMPORT bool enable_gathermerge;
|
||||||
extern PGDLLIMPORT bool enable_partition_wise_join;
|
extern PGDLLIMPORT bool enable_partitionwise_join;
|
||||||
extern PGDLLIMPORT bool enable_parallel_append;
|
extern PGDLLIMPORT bool enable_parallel_append;
|
||||||
extern PGDLLIMPORT bool enable_parallel_hash;
|
extern PGDLLIMPORT bool enable_parallel_hash;
|
||||||
extern PGDLLIMPORT int constraint_exclusion;
|
extern PGDLLIMPORT int constraint_exclusion;
|
||||||
|
|
|
@ -58,7 +58,7 @@ extern int compute_parallel_worker(RelOptInfo *rel, double heap_pages,
|
||||||
double index_pages, int max_workers);
|
double index_pages, int max_workers);
|
||||||
extern void create_partial_bitmap_paths(PlannerInfo *root, RelOptInfo *rel,
|
extern void create_partial_bitmap_paths(PlannerInfo *root, RelOptInfo *rel,
|
||||||
Path *bitmapqual);
|
Path *bitmapqual);
|
||||||
extern void generate_partition_wise_join_paths(PlannerInfo *root,
|
extern void generate_partitionwise_join_paths(PlannerInfo *root,
|
||||||
RelOptInfo *rel);
|
RelOptInfo *rel);
|
||||||
|
|
||||||
#ifdef OPTIMIZER_DEBUG
|
#ifdef OPTIMIZER_DEBUG
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
--
|
--
|
||||||
-- PARTITION_JOIN
|
-- PARTITION_JOIN
|
||||||
-- Test partition-wise join between partitioned tables
|
-- Test partitionwise join between partitioned tables
|
||||||
--
|
--
|
||||||
-- Enable partition-wise join, which by default is disabled.
|
-- Enable partitionwise join, which by default is disabled.
|
||||||
SET enable_partition_wise_join to true;
|
SET enable_partitionwise_join to true;
|
||||||
--
|
--
|
||||||
-- partitioned by a single column
|
-- partitioned by a single column
|
||||||
--
|
--
|
||||||
|
@ -1578,7 +1578,7 @@ SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_l WHERE prt1_l.b = 0) t1
|
||||||
| | 525 | 0001
|
| | 525 | 0001
|
||||||
(16 rows)
|
(16 rows)
|
||||||
|
|
||||||
-- lateral partition-wise join
|
-- lateral partitionwise join
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT * FROM prt1_l t1 LEFT JOIN LATERAL
|
SELECT * FROM prt1_l t1 LEFT JOIN LATERAL
|
||||||
(SELECT t2.a AS t2a, t2.c AS t2c, t2.b AS t2b, t3.b AS t3b, least(t1.a,t2.a,t3.b) FROM prt1_l t2 JOIN prt2_l t3 ON (t2.a = t3.b AND t2.c = t3.c)) ss
|
(SELECT t2.a AS t2a, t2.c AS t2c, t2.b AS t2b, t3.b AS t3b, least(t1.a,t2.a,t3.b) FROM prt1_l t2 JOIN prt2_l t3 ON (t2.a = t3.b AND t2.c = t3.c)) ss
|
||||||
|
@ -1695,7 +1695,7 @@ CREATE TABLE prt4_n_p2 PARTITION OF prt4_n FOR VALUES FROM (300) TO (500);
|
||||||
CREATE TABLE prt4_n_p3 PARTITION OF prt4_n FOR VALUES FROM (500) TO (600);
|
CREATE TABLE prt4_n_p3 PARTITION OF prt4_n FOR VALUES FROM (500) TO (600);
|
||||||
INSERT INTO prt4_n SELECT i, i, to_char(i, 'FM0000') FROM generate_series(0, 599, 2) i;
|
INSERT INTO prt4_n SELECT i, i, to_char(i, 'FM0000') FROM generate_series(0, 599, 2) i;
|
||||||
ANALYZE prt4_n;
|
ANALYZE prt4_n;
|
||||||
-- partition-wise join can not be applied if the partition ranges differ
|
-- partitionwise join can not be applied if the partition ranges differ
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt4_n t2 WHERE t1.a = t2.a;
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt4_n t2 WHERE t1.a = t2.a;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
|
@ -1742,7 +1742,7 @@ SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt4_n t2, prt2 t3 WHERE t1.a = t2.a
|
||||||
-> Seq Scan on prt2_p3 t3_2
|
-> Seq Scan on prt2_p3 t3_2
|
||||||
(23 rows)
|
(23 rows)
|
||||||
|
|
||||||
-- partition-wise join can not be applied if there are no equi-join conditions
|
-- partitionwise join can not be applied if there are no equi-join conditions
|
||||||
-- between partition keys
|
-- between partition keys
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 LEFT JOIN prt2 t2 ON (t1.a < t2.b);
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 LEFT JOIN prt2 t2 ON (t1.a < t2.b);
|
||||||
|
@ -1763,7 +1763,7 @@ SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 LEFT JOIN prt2 t2 ON (t1.a < t2.b);
|
||||||
(12 rows)
|
(12 rows)
|
||||||
|
|
||||||
-- equi-join with join condition on partial keys does not qualify for
|
-- equi-join with join condition on partial keys does not qualify for
|
||||||
-- partition-wise join
|
-- partitionwise join
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1, prt2_m t2 WHERE t1.a = (t2.b + t2.a)/2;
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1, prt2_m t2 WHERE t1.a = (t2.b + t2.a)/2;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
|
@ -1782,7 +1782,7 @@ SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1, prt2_m t2 WHERE t1.a = (t2.b + t2.
|
||||||
(11 rows)
|
(11 rows)
|
||||||
|
|
||||||
-- equi-join between out-of-order partition key columns does not qualify for
|
-- equi-join between out-of-order partition key columns does not qualify for
|
||||||
-- partition-wise join
|
-- partitionwise join
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.a = t2.b;
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.a = t2.b;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
|
@ -1800,7 +1800,7 @@ SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.a = t2.b;
|
||||||
-> Seq Scan on prt2_m_p3 t2_2
|
-> Seq Scan on prt2_m_p3 t2_2
|
||||||
(11 rows)
|
(11 rows)
|
||||||
|
|
||||||
-- equi-join between non-key columns does not qualify for partition-wise join
|
-- equi-join between non-key columns does not qualify for partitionwise join
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.c = t2.c;
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.c = t2.c;
|
||||||
QUERY PLAN
|
QUERY PLAN
|
||||||
|
@ -1818,7 +1818,7 @@ SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.c = t2.c;
|
||||||
-> Seq Scan on prt2_m_p3 t2_2
|
-> Seq Scan on prt2_m_p3 t2_2
|
||||||
(11 rows)
|
(11 rows)
|
||||||
|
|
||||||
-- partition-wise join can not be applied between tables with different
|
-- partitionwise join can not be applied between tables with different
|
||||||
-- partition lists
|
-- partition lists
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 LEFT JOIN prt2_n t2 ON (t1.c = t2.c);
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 LEFT JOIN prt2_n t2 ON (t1.c = t2.c);
|
||||||
|
@ -1857,7 +1857,7 @@ SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 JOIN prt2_n t2 ON (t1.c = t2.c) JOI
|
||||||
-> Seq Scan on prt1_n_p2 t1_1
|
-> Seq Scan on prt1_n_p2 t1_1
|
||||||
(16 rows)
|
(16 rows)
|
||||||
|
|
||||||
-- partition-wise join can not be applied for a join between list and range
|
-- partitionwise join can not be applied for a join between list and range
|
||||||
-- partitioned table
|
-- partitioned table
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 FULL JOIN prt1 t2 ON (t1.c = t2.c);
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 FULL JOIN prt1 t2 ON (t1.c = t2.c);
|
||||||
|
|
|
@ -71,7 +71,7 @@ select count(*) >= 0 as ok from pg_prepared_xacts;
|
||||||
-- a regression test run.
|
-- a regression test run.
|
||||||
select name, setting from pg_settings where name like 'enable%';
|
select name, setting from pg_settings where name like 'enable%';
|
||||||
name | setting
|
name | setting
|
||||||
----------------------------+---------
|
---------------------------+---------
|
||||||
enable_bitmapscan | on
|
enable_bitmapscan | on
|
||||||
enable_gathermerge | on
|
enable_gathermerge | on
|
||||||
enable_hashagg | on
|
enable_hashagg | on
|
||||||
|
@ -83,7 +83,7 @@ select name, setting from pg_settings where name like 'enable%';
|
||||||
enable_nestloop | on
|
enable_nestloop | on
|
||||||
enable_parallel_append | on
|
enable_parallel_append | on
|
||||||
enable_parallel_hash | on
|
enable_parallel_hash | on
|
||||||
enable_partition_wise_join | off
|
enable_partitionwise_join | off
|
||||||
enable_seqscan | on
|
enable_seqscan | on
|
||||||
enable_sort | on
|
enable_sort | on
|
||||||
enable_tidscan | on
|
enable_tidscan | on
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
--
|
--
|
||||||
-- PARTITION_JOIN
|
-- PARTITION_JOIN
|
||||||
-- Test partition-wise join between partitioned tables
|
-- Test partitionwise join between partitioned tables
|
||||||
--
|
--
|
||||||
|
|
||||||
-- Enable partition-wise join, which by default is disabled.
|
-- Enable partitionwise join, which by default is disabled.
|
||||||
SET enable_partition_wise_join to true;
|
SET enable_partitionwise_join to true;
|
||||||
|
|
||||||
--
|
--
|
||||||
-- partitioned by a single column
|
-- partitioned by a single column
|
||||||
|
@ -306,7 +306,7 @@ EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_l WHERE prt1_l.b = 0) t1 FULL JOIN (SELECT * FROM prt2_l WHERE prt2_l.a = 0) t2 ON (t1.a = t2.b AND t1.c = t2.c) ORDER BY t1.a, t2.b;
|
SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_l WHERE prt1_l.b = 0) t1 FULL JOIN (SELECT * FROM prt2_l WHERE prt2_l.a = 0) t2 ON (t1.a = t2.b AND t1.c = t2.c) ORDER BY t1.a, t2.b;
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_l WHERE prt1_l.b = 0) t1 FULL JOIN (SELECT * FROM prt2_l WHERE prt2_l.a = 0) t2 ON (t1.a = t2.b AND t1.c = t2.c) ORDER BY t1.a, t2.b;
|
SELECT t1.a, t1.c, t2.b, t2.c FROM (SELECT * FROM prt1_l WHERE prt1_l.b = 0) t1 FULL JOIN (SELECT * FROM prt2_l WHERE prt2_l.a = 0) t2 ON (t1.a = t2.b AND t1.c = t2.c) ORDER BY t1.a, t2.b;
|
||||||
|
|
||||||
-- lateral partition-wise join
|
-- lateral partitionwise join
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT * FROM prt1_l t1 LEFT JOIN LATERAL
|
SELECT * FROM prt1_l t1 LEFT JOIN LATERAL
|
||||||
(SELECT t2.a AS t2a, t2.c AS t2c, t2.b AS t2b, t3.b AS t3b, least(t1.a,t2.a,t3.b) FROM prt1_l t2 JOIN prt2_l t3 ON (t2.a = t3.b AND t2.c = t3.c)) ss
|
(SELECT t2.a AS t2a, t2.c AS t2c, t2.b AS t2b, t3.b AS t3b, least(t1.a,t2.a,t3.b) FROM prt1_l t2 JOIN prt2_l t3 ON (t2.a = t3.b AND t2.c = t3.c)) ss
|
||||||
|
@ -348,39 +348,39 @@ CREATE TABLE prt4_n_p3 PARTITION OF prt4_n FOR VALUES FROM (500) TO (600);
|
||||||
INSERT INTO prt4_n SELECT i, i, to_char(i, 'FM0000') FROM generate_series(0, 599, 2) i;
|
INSERT INTO prt4_n SELECT i, i, to_char(i, 'FM0000') FROM generate_series(0, 599, 2) i;
|
||||||
ANALYZE prt4_n;
|
ANALYZE prt4_n;
|
||||||
|
|
||||||
-- partition-wise join can not be applied if the partition ranges differ
|
-- partitionwise join can not be applied if the partition ranges differ
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt4_n t2 WHERE t1.a = t2.a;
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt4_n t2 WHERE t1.a = t2.a;
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt4_n t2, prt2 t3 WHERE t1.a = t2.a and t1.a = t3.b;
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1, prt4_n t2, prt2 t3 WHERE t1.a = t2.a and t1.a = t3.b;
|
||||||
|
|
||||||
-- partition-wise join can not be applied if there are no equi-join conditions
|
-- partitionwise join can not be applied if there are no equi-join conditions
|
||||||
-- between partition keys
|
-- between partition keys
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 LEFT JOIN prt2 t2 ON (t1.a < t2.b);
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1 t1 LEFT JOIN prt2 t2 ON (t1.a < t2.b);
|
||||||
|
|
||||||
-- equi-join with join condition on partial keys does not qualify for
|
-- equi-join with join condition on partial keys does not qualify for
|
||||||
-- partition-wise join
|
-- partitionwise join
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1, prt2_m t2 WHERE t1.a = (t2.b + t2.a)/2;
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1, prt2_m t2 WHERE t1.a = (t2.b + t2.a)/2;
|
||||||
|
|
||||||
-- equi-join between out-of-order partition key columns does not qualify for
|
-- equi-join between out-of-order partition key columns does not qualify for
|
||||||
-- partition-wise join
|
-- partitionwise join
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.a = t2.b;
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.a = t2.b;
|
||||||
|
|
||||||
-- equi-join between non-key columns does not qualify for partition-wise join
|
-- equi-join between non-key columns does not qualify for partitionwise join
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.c = t2.c;
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_m t1 LEFT JOIN prt2_m t2 ON t1.c = t2.c;
|
||||||
|
|
||||||
-- partition-wise join can not be applied between tables with different
|
-- partitionwise join can not be applied between tables with different
|
||||||
-- partition lists
|
-- partition lists
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 LEFT JOIN prt2_n t2 ON (t1.c = t2.c);
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 LEFT JOIN prt2_n t2 ON (t1.c = t2.c);
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 JOIN prt2_n t2 ON (t1.c = t2.c) JOIN plt1 t3 ON (t1.c = t3.c);
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 JOIN prt2_n t2 ON (t1.c = t2.c) JOIN plt1 t3 ON (t1.c = t3.c);
|
||||||
|
|
||||||
-- partition-wise join can not be applied for a join between list and range
|
-- partitionwise join can not be applied for a join between list and range
|
||||||
-- partitioned table
|
-- partitioned table
|
||||||
EXPLAIN (COSTS OFF)
|
EXPLAIN (COSTS OFF)
|
||||||
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 FULL JOIN prt1 t2 ON (t1.c = t2.c);
|
SELECT t1.a, t1.c, t2.b, t2.c FROM prt1_n t1 FULL JOIN prt1 t2 ON (t1.c = t2.c);
|
||||||
|
|
Loading…
Reference in New Issue