How to use Snowflake with pgEdge

Snowflake provide sequences for a distributed PostgreSQL cluster, this article is about using snowflake sequences for pgEdge cluster.

pgEdge automatically installs and creates the snowflake extension.

The spock node-create command has been updated to set the snowflake node id for you. This is dependent on naming the node ‘N1’, ‘N2’, ‘N3’ up to ‘N9’. If you use another node id name, then you have to manually set snowflake.node to a unique value in your cluster. 

./nc spock node-create n2 'host=10.2.1.2 user=pgedge port=5432 dbname=demo' demo

[

  {

"node_create": 560818415

  }

]

  new: snowflake.node = 2

#   ./nc reload pg16

pg16 reloading

#   /home/pgedge/pg16/bin/pg_ctl reload -D "/home/pgedge/data/pg16"

server signaled

There is also a CLI command for converting your existing sequences into snowflake sequences. Similar to the spock repset-add-table command, the sequence value here can be the full name of a sequence, or a like expression using * as a wildcard.

./nc spock sequence-convert --help


SYNOPSIS

./ctl spock sequence-convert SEQUENCE DB <flags>


DESCRIPTION

Convert sequence to snowflake sequence.


POSITIONAL ARGUMENTS

SEQUENCE

DB


FLAGS

-t, --type=TYPE

     Default: 'snowflake'

Example:

./ctl spock sequence-convert public.* postgres

Where you want to convert all sequences in the public schema within the postgres database. 

This article is submitted by Cady Motyka.