Using CRDTs v5.6
Using CRDTs in tables
Permissions required
PGD CRDTs requires usage access to CRDT types. Therefore, any user needing to access CRDT types must have at least the bdr_application role assigned to them.
To use CRDTs, you need to use a particular data type in CREATE/ALTER TABLE rather than standard built-in data types such as integer
. For example, consider the following table with one regular integer counter and a single row:
Non-CRDT example
Suppose you issue the following SQL on two different nodes at same time:
After both updates are applied, you can see the resulting values using this query:
This code shows that you lost one of the increments due to the update_if_newer
conflict resolver.
CRDT example
To use a CRDT counter data type instead, you would follow these steps:
Create the table but with a CRDT (bdr.crdt_gcounter
) as the counters data type.