CREATE NODE nodename WITH ( [ TYPE = nodetype,] [ HOST = hostname,] [ PORT = portnum,] [ PRIMARY [ = boolean ],] [ PREFERRED [ = boolean ] ] )
Note: XCONLY: The following description applies only to Postgres-XC.
CREATE NODE is new SQL query specific to Postgres-XC since 0.9.7 that creates a new entry in catalog table pgxc_node with node data.
This node data is directly used by a Coordinator session when connecting to build connection data to cluster nodes through Postgres-XC pooler.
Node connection information is created on pooler only if it has not been the case yet on Coordinator connected at the moment of connection.
CREATE NODE only runs on the local node where it is launched.
The name of the selected cluster node.
The type of the cluster node. It is possible to specify a Coordinator node or a Datanode node.
Defines if the cluster node is used as a primary node for replicated write operations. A boolean value can be specified. In case no value is specified, PRIMARY acts like false.
To avoid deadlock and make update consistetnt, you should specify the same PRIMARY node at all the nodes.
Defines if the cluster node is used as a preferred node for replicated read operations if no node is determined. A boolean value can be specified. In case no value is specified, PREFERRED acts like false.
You can specify different PREFERRED node at different coordinator. This parameter affects performance of your Postgres-XC cluster. If you configure a datanode where you configure a coordinator, you should specify PREFERRED for the coordinator to such a local datanode. This will save network communication and improve cluster-wide performance.
The node type for given cluster node. Possible values are: 'coordinator' for a Coordinator node and 'datanode' for a Datanode node.
The hostname or IP used to connect to the cluster node.
The port number used to connect to the cluster node.
nodename remains constant as long as it is in use.
When using a cluster with 1 Coordinator and 1 Datanode on each server, Defining the local Datanode as PREFERRED can greatly improve the performance of a system by avoiding any network overhead for replicated reads, as in this case a local socket is used for communication between nodes. This has even more effects when the application uses heavily replicated table for remote join operations and that those operations can be operated on the local PREFERRED node.
Create a Coordinator node located on local machine using port 6543
CREATE NODE node2 WITH (TYPE = 'coordinator', HOST = 'localhost', PORT = 6543);
Create a Datanode which is a preferred and primary node located on remote machine with IP '192.168.0.3' on port 8888.
CREATE NODE node2 WITH (TYPE = 'datanode', HOST = '192.168.0.3', PORT = 8888, PRIMARY, PREFERRED);
CREATE NODE does not conform to the SQL standards, it is a Postgres-XC specific command.