pull/7572/head
Vinod Sridharan 2024-04-04 00:33:06 +00:00
parent e989e5b00e
commit 45804c0e5d
5 changed files with 20 additions and 1 deletions

View File

@ -54,6 +54,9 @@
#include "distributed/transaction_management.h" #include "distributed/transaction_management.h"
#include "distributed/worker_manager.h" #include "distributed/worker_manager.h"
/* Config variables managed via guc */
bool EnableSingleShardTableMultiNodePlacement = false;
/* declarations for dynamic loading */ /* declarations for dynamic loading */
PG_FUNCTION_INFO_V1(master_create_worker_shards); PG_FUNCTION_INFO_V1(master_create_worker_shards);
@ -165,7 +168,8 @@ CreateShardsWithRoundRobinPolicy(Oid distributedTableId, int32 shardCount,
char shardStorageType = ShardStorageType(distributedTableId); char shardStorageType = ShardStorageType(distributedTableId);
int64 shardOffset = 0; int64 shardOffset = 0;
if (shardCount == 1 && shardStorageType == SHARD_STORAGE_TABLE) if (EnableSingleShardTableMultiNodePlacement && shardCount == 1
&& shardStorageType == SHARD_STORAGE_TABLE)
{ {
/* For single shard distributed tables, use the colocationId to offset /* For single shard distributed tables, use the colocationId to offset
* where the shard is placed. * where the shard is placed.

View File

@ -86,6 +86,7 @@
#include "distributed/multi_router_planner.h" #include "distributed/multi_router_planner.h"
#include "distributed/multi_server_executor.h" #include "distributed/multi_server_executor.h"
#include "distributed/pg_dist_partition.h" #include "distributed/pg_dist_partition.h"
#include "distributed/pg_dist_shard.h"
#include "distributed/placement_connection.h" #include "distributed/placement_connection.h"
#include "distributed/priority.h" #include "distributed/priority.h"
#include "distributed/query_pushdown_planning.h" #include "distributed/query_pushdown_planning.h"
@ -1462,6 +1463,17 @@ RegisterCitusConfigVariables(void)
GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE, GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE,
NULL, NULL, NULL); NULL, NULL, NULL);
DefineCustomBoolVariable(
"citus.enable_single_shard_table_multi_node_placement",
gettext_noop("Enables placement of single shard distributed tables in"
" all nodes of the cluster"),
NULL,
&EnableSingleShardTableMultiNodePlacement,
false,
PGC_USERSET,
GUC_NO_SHOW_ALL | GUC_NOT_IN_SAMPLE,
NULL, NULL, NULL);
DefineCustomBoolVariable( DefineCustomBoolVariable(
"citus.enable_statistics_collection", "citus.enable_statistics_collection",
gettext_noop("Enables sending basic usage statistics to Citus."), gettext_noop("Enables sending basic usage statistics to Citus."),

View File

@ -59,5 +59,6 @@ typedef FormData_pg_dist_shard *Form_pg_dist_shard;
#define SHARD_STORAGE_TABLE 't' #define SHARD_STORAGE_TABLE 't'
#define SHARD_STORAGE_VIRTUAL 'v' #define SHARD_STORAGE_VIRTUAL 'v'
extern bool EnableSingleShardTableMultiNodePlacement;
#endif /* PG_DIST_SHARD_H */ #endif /* PG_DIST_SHARD_H */

View File

@ -468,6 +468,7 @@ DROP TABLE temp_table;
DROP TABLE shard_count_table_3; DROP TABLE shard_count_table_3;
-- test shard count 1 placement with colocate none. -- test shard count 1 placement with colocate none.
-- create a base table instance -- create a base table instance
set citus.enable_single_hash_repartition_joins to on;
CREATE TABLE shard_count_table_1_inst_1 (a int); CREATE TABLE shard_count_table_1_inst_1 (a int);
SELECT create_distributed_table('shard_count_table_1_inst_1', 'a', shard_count:=1, colocate_with:='none'); SELECT create_distributed_table('shard_count_table_1_inst_1', 'a', shard_count:=1, colocate_with:='none');
create_distributed_table create_distributed_table

View File

@ -294,6 +294,7 @@ DROP TABLE shard_count_table_3;
-- test shard count 1 placement with colocate none. -- test shard count 1 placement with colocate none.
-- create a base table instance -- create a base table instance
set citus.enable_single_hash_repartition_joins to on;
CREATE TABLE shard_count_table_1_inst_1 (a int); CREATE TABLE shard_count_table_1_inst_1 (a int);
SELECT create_distributed_table('shard_count_table_1_inst_1', 'a', shard_count:=1, colocate_with:='none'); SELECT create_distributed_table('shard_count_table_1_inst_1', 'a', shard_count:=1, colocate_with:='none');