Skip to content

Custom SQL reference

Alessandro Luccaroni edited this page Jul 7, 2020 · 1 revision

Custom SQL reference

This page covers SQL reference for custom SQL syntax for Herd specific model

TableSpace DDL Syntax

CREATE TABLESPACE TABLESPACENAME,'property:value','property:value'....

ALTER TABLESPACE TABLESPACENAME,'property:value','property:value'....

Supported properties

  • leader: the ID of the node which is designed as 'leader' for the tablespace
  • replica: comma separated list of the IDs of the nodes which are designed to replicate data for the tablespace, the leader MUST be included in this list
  • expectedReplicaCount: the number of expected replica node for the tablespace, in case of underreplication HerdDB will assign new nodes to the replica
  • wait: time to wait in milliseconds for the leader of the tablespace to start the tablespace (available only for the CREATE TABLESPACE COMMAND)

If you create a tablespace and do not set a leader the leader will be the node which executes the statement

Tablespace DDL statements can be executed on any node, not only on replicas

Note: property names are not case sensitive. Tablespace names and Node IDs are case sensitive

Examples

CREATE TABLESPACE 'mytablespace'

CREATE TABLESPACE 'mytablespace','leader:server1','wait:60000'

ALTER TABLESPACE 'mytablespace','expectedreplicacount:5'

Troubleshoting

You can inspect the SYSTABLESSPACES table and the SYSTABLESPACEREPLICASTATE table in order to see the actual status of the system. This virtual tables can be queried on any tablespace, and thus on any node. Remember that every node has a special tablespace which has the nodeid as name, this way you can redirect your queries to a specific node of the cluster, because the SQL client connects to the 'leader' node of the specified tablespace for each SQL statement.

SELECT * FROM SYSTABLESPACES

SELECT * FROM SYSTABLESPACEREPLICASTATE
Clone this wiki locally